0

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 .

4

1 回答 1

1

请记住,如果此时您将 websocket 委托设为 nil,则当套接字实际关闭时(它不是中间的),将没有委托来处理该webSocket:diCloseWithCode:事件。但是无论如何,套接字肯定应该关闭。

可能不是这样,但只发送关闭消息会更有意义。然后等待 didClose 和那里,你可以 nil 委托和实际的 _websocket。

于 2014-08-18T11:36:01.073 回答