I'm working on an application which can send out files and actions to users. Users can request a file at any time from the server (client server model). Sometimes files can be fairly large (e.g 10 mb) which whilst sending can delay the other small actions from being sent to connected users. It seems that Gamekit has one thread for sending and a separate one for receiving.
I am wondering if it is possible to have an additional sending thread to ensure the smaller action packets do not have to wait for a large file to be sent. I have tried to create a queue with grand central dispatch but unfortunately the sending still only appeared to use one thread.
dispatch_async(pdfSendQ, ^{
NSString *filePath = [_document.fileURL path] ;
if (!_pdfNSData)
_pdfNSData = [NSData dataWithContentsOfFile:filePath];
for(NSData* packet in self.packets) {
NSError* error = nil;
[_session sendData:packet toPeers:[NSArray arrayWithObject:peerID] withDataMode:GKSendDataReliable error:&error];
if(error != nil) {
[[NSNotificationCenter defaultCenter] postNotificationName:kPacketFailedNotification object:self userInfo:[NSDictionary dictionaryWithObject:error forKey:@"error"]];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:kPacketSentNotification object:self];
}
}
[[NSNotificationCenter defaultCenter] postNotificationName:kFileSentNotification object:self];
});
I guess it would be possible to get the separate smaller action packets to 'interrupt' the large file sending, however this would be fairly complex and I was wondering if there was a much simpler way.