I am using SocketRocket, but I cannot get it to deliver messages while in the background. When I open the app again, it resumes the connection (without reconnecting) and the messages all come in at once.
Here is my connection code:
- (void)_reconnect {
_websocket.delegate = nil;
[_websocket close];
NSString *host = @"ws://localhost:3030/primus";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:host]];
[request setValue:[NSString stringWithFormat:@"<%@>", apiKey] forHTTPHeaderField:@"Authentication"];
_websocket = [[SRWebSocket alloc] initWithURLRequest:request];
[_websocket setDelegateOperationQueue:[NSOperationQueue new]];
_websocket.delegate = self;
[_websocket open];
if (DEBUG) {
NSLog(@"Using: %@", host);
}
}
I have also tried without the
[_websocket setDelegateOperationQueue:[NSOperationQueue new]];
line, but that doesn't help anything.
Do you have any idea what's going on?
Thanks!