-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the disconnected callback #787
Comments
This works for me:
`socket = WebSocket(request: request) socket.delegate = self socket.connect() // to connect socket.disconnect()` //Implement the below function:
|
Jumping in to mention that v4.0.4 is not receiving the callback either. I just upgraded from 3.0.6 and the same event (killing the socket server) does not produce a callback message. I also wish there was a clear note about what events send which delegate event. |
some workaround? |
My work around was to go to the last available 3.x.x version in CocoaPods. Doing that reverted to the earlier delegate structure and I haven't had any problems. |
@wesgood I went back to 3.0.6 due to the disconnect event not working well |
I also had the same problem with v4.0.4 I downgraded to 3.0.6 and the disconnect event worked fine |
Came here just to mention that v4.0.6 still has this issue 😢 |
Also #821 fixes that behaviour and everything works well. |
If I use version 3.1.1.
When the server is closed or the connection fails, use this method ( func websocketDidDisconnect) to receive a callback.
But if I use 4.0.3 ,
There is no callback when the server is closed or the connection fails.
func didReceive(event: WebSocketEvent, client: WebSocket) {
switch event {
case .connected(let headers):
isConnected = true
print("websocket is connected: (headers)")
case .disconnected(let reason, let code):
isConnected = false
print("websocket is disconnected: (reason) with code: (code)")
case .text(let string):
print("Received text: (string)")
case .binary(let data):
print("Received data: (data.count)")
case .ping():
break
case .pong():
break
case .viablityChanged():
break
case .reconnectSuggested():
break
case .cancelled:
isConnected = false
case .error(let error):
isConnected = false
handleError(error)
}
}
This fun no run ?How to get the disconnected callback in 4.0.3
The text was updated successfully, but these errors were encountered: