Open zhuozhuo opened 8 years ago
@zhuozhuo Hi! Please post here the code that you use for sending that file.
Also please note that sendFrame()/broadcastFrame() methods send frames of arbitrary size atomically — so usually you can send image in one frame without splitting it into multiple frames.
NSInteger bufferLenth = 1024;
NSString *path = [[NSBundle mainBundle]pathForResource:@"test" ofType:@"img"];
NSData *imgData = [NSData dataWithContentsOfFile:path];
NSLog(@"imgDataLength:%ld",imgData.length);
NSInteger sendDataIndex = 0;
while (sendDataIndex<imgData.length) {
NSInteger amountToSend = imgData.length - sendDataIndex;
if (amountToSend > bufferLenth) {
amountToSend = bufferLenth;
}
NSData *sendData = [NSData dataWithBytes:(imgData.bytes + sendDataIndex) length:amountToSend];
[darkNode broadcastFrame:sendData];
sendDataIndex += amountToSend;
}
@zhuozhuo I don't understand what does the while loop do in your code. Why are you looping through image bytes?
Also please re-read my previous message about frame.
Basically all you want to do is following without any loops:
NSString *path = [[NSBundle mainBundle]pathForResource:@"test" ofType:@"img"];
NSData *imgData = [NSData dataWithContentsOfFile:path];
[darkNode broadcastFrame: imgData];
Also how big is your image file?
500M
@zhuozhuo iOS and Android devices don't have enough RAM to have such file in memory. So you can't even just call [NSData dataWithContentsOfFile:path];
You must load it from disk in chunks and send these chunks over a network one at a time, with confirmation from receiving side before sending next chunk.
I think so, but I can't see success to receive the callback function interface you provided.
@zhuozhuo Such receive confirmation callback is planned for future version of the library.
For now, you can emulate it by sending your own special frame from the receiver back to the sender with (for example) index of received chunk. And when sender receives such confirmation, it can load the next chunk of the image file from the disk and send it over network.
Thank you, I see, looking forward to the next version.
@zhuozhuo I recommend to try to emulate it for now — it must be quite simple.
I will leave this Issue open and post to you when this functionality will be implemented in the library.
Thanks again. If I have any questions to ask you again.
By the way, why you need to transfer so large image file? What is it for?
The system upgrade to the android intelligent watch send documents.Img file generated by the terminal.
What for?
On 19 Jan 2016, at 04:51, Mr.jiang notifications@github.com wrote:
The system upgrade to the android intelligent watch send documents.Img file generated by the terminal.
— Reply to this email directly or view it on GitHub.
The img file just a test. In order to send android smart watch system upgrade file.
Hi,In the wifi environment, how to speed up the transmission speed!
@zhuozhuo Library uses standard sockets for Wi-Fi transfer, so it must work with full speed of your Wi-Fi. Maybe there is room for some optimizations in the code — I'll look at them later.
ok,thanks!
Hi, I want transfer large file with iPhone and android。To send data to the android on the iPhone side,on the iPhone side memory has been increased to collapse。Do you have any good Suggestions? Thanks!