Hi,
I've got an object from type NSURLSessionWebSocketTask from which I create webSocket.
However, currently it can only receive responses as can be seen here:
NSURLSessionWebSocketMessage * msg = [[NSURLSessionWebSocketMessage alloc] initWithString:myStringBody;
[socketConnection sendMessage:msg completionHandler: ^(NSError * e) {
if (e == nil) {
[socketConnection receiveMessageWithCompletionHandler:^(NSURLSessionWebSocketMessage * _Nullable message, NSError * _Nullable error) {
NSLog(@"got message = %@", message.string);
}];
}];
I'd like to be able to receive messages from server that wasn't triggered from client request (messages that initiated by the server).
Ideally, i wish to get them in some sort of queue (maybe NSOperationQueue or dispatch queue). But the bottomline should be that some listener would work in the background.
Perhaps there's some delegate to implement this requirement ?