You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 13, 2024. It is now read-only.
On Swift 4+, connecting to a web socket on an esp8266. When I restart the ESP, the socket is obviously closed, but none of the events fire in the swift code. Tried with the event methods and delegate methods....
//~~
socket = WebSocket("ws://" + IP + ":" + String(port))
socket.delegate = self
socket.open()
socket.event.error = { (e) in
print("SOCKET ERROR \(e)")
}
socket.event.close = { code, reason, clean in
print("closed due to code \(code), reason \(reason), clean \(clean)")
}
socket.event.end = {code, reason, clean, error in
print("end due to code \(code), reason \(reason), clean \(clean), error \(String(describing: error))")
}
//~~
extension WebSocketClient: WebSocketDelegate{
func webSocketMessageText(_ text: String) {
NotificationCenter.default.post(Notification(name: Notification.Name(rawValue:Constants.WEBSocketMessageReceived),object: self,userInfo: ["message": text]))
}
func webSocketMessageData(_ data: Data) {
print("Websocket received data \(data)")
}
func webSocketOpen() {
print("WEBSocket opened to \(IP):\(port)")
connected = true
observer.connected(client: self)
}
func webSocketClose(_ code: Int, reason: String, wasClean: Bool) {
print("WEBSocket closed to \(IP):\(port)")
connected = false
observer.disconnected(client: self)
}
func webSocketError(_ error: NSError) {
print("WEBSocket error on \(IP):\(port)")
}
func webSocketEnd(_ code: Int, reason: String, wasClean: Bool, error: NSError?) {
print("WEBSocket closed to \(IP):\(port)")
connected = false
observer.disconnected(client: self)
}
}
The text was updated successfully, but these errors were encountered:
chadham
changed the title
close, end, error not called when socket is closed at the other end
close, end, error never called when socket is killed (non gracefully) at the other end
Mar 24, 2018
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
On Swift 4+, connecting to a web socket on an esp8266. When I restart the ESP, the socket is obviously closed, but none of the events fire in the swift code. Tried with the event methods and delegate methods....
The text was updated successfully, but these errors were encountered: