user3115014
user3115014

Reputation: 697

SRWebsocket close the connection ios

I am using SRWebsocket in my connection class I am trying to disconnect the socket when the app goes to background i have tried these things

SRWebSocket *_webSocket;


-(void)close

{


    [_webSocket close];
    _webSocket.delegate = nil;
    _webSocket = nil;


}

but it is not closing the socket please help me in doing so .

Upvotes: 0

Views: 1822

Answers (1)

gzafra
gzafra

Reputation: 496

Keep in mind that, if you nil the websocket delegate at this point, when the socket actually closes (it's not inmediate), there will be no delegate to process the webSocket:diCloseWithCode: event. But the socket should certainly be closed anyway.

It may not be that, but it would make more sense to just send the close message. Then wait for the didClose and there, you can nil both the delegate and the actual _websocket.

Upvotes: 1

Related Questions