Hello!
Since some time I've been playing with GameKit, but now I'm facing relly bad difficulties.
I'm going to send through Bluetooth bigger files - 1-2MB. I've already prepared a packets (about 8kB each).
My app works as described on followin scheme:
iPhone - sending header: file divided into 25 parts
iPod - received header: OK I got it waiting for 25 parts
iPhone - sending part #1
iPod - received part #1 send next
iPhone - sending part #2
iPod - received part #2 send next
...
iPhone - sending part #24
iPod - received part #24 send next
iPhone - sending part #25
iPod receiving part #25 processing file
I send both file parts and messages (confirmation od delivery) using:
[mSession sendData:data toPeers:mPeers withDataMode:GKSendDataReliable error:nil];
and receiving data:
- (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context
I would like to know how do you deal with some problems that may occure during bluetooth transmission. Browsing the documentations GKSessionDelegate doesn't give me any info if the data was delivered or not.
In 90% cases the transfer works fine, but sometimes it suddenly stops and doesn't continue without reconnection/restart the app.
I triend to invent a easy solution to set the data again if I won't get the response within 1sec:
-(void)sendAgain {
[self sendData:bufor];
}
-(void)sendData:(NSData *)data {
bufor = [data retain];
timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(sendAgain) userInfo:nil repeats:NO];
[mSession sendData:data toPeers:mPeers withDataMode:GKSendDataReliable error:nil];
}
timeOutTimer is invalidated if sender received confirmation of succesful delivery of file part. But in fact when I implement this solution there are even more problems with this.
Devices are next to each other on the desk.
So guys, please tell me, how do you deal with problems of "undelivered" data between devices? It's just a tool, but how it could be annoying while developing games?
BTW Sending short chats messages never caused any problem and I'm using the same methods.
In fact the connection get lost very rarely, just the data likes to be lost in the air. I'm already dividing the parts so the size of the data is about 8kb, what really makes the transfer of images really really slow.