This commit is contained in:
parent
eeadccec94
commit
fcebc870c3
@ -40,6 +40,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
|||||||
private var fastUpgrade = false
|
private var fastUpgrade = false
|
||||||
private var forcePolling = false
|
private var forcePolling = false
|
||||||
private var forceWebsockets = false
|
private var forceWebsockets = false
|
||||||
|
private var gotPong = true
|
||||||
private var pingTimer:NSTimer?
|
private var pingTimer:NSTimer?
|
||||||
private var postWait = [String]()
|
private var postWait = [String]()
|
||||||
private var _polling = true
|
private var _polling = true
|
||||||
@ -516,6 +517,8 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
|||||||
} else if type == PacketType.NOOP {
|
} else if type == PacketType.NOOP {
|
||||||
doPoll()
|
doPoll()
|
||||||
} else if type == PacketType.PONG {
|
} else if type == PacketType.PONG {
|
||||||
|
gotPong = true
|
||||||
|
|
||||||
// We should upgrade
|
// We should upgrade
|
||||||
if message == "3probe" {
|
if message == "3probe" {
|
||||||
upgradeTransport()
|
upgradeTransport()
|
||||||
@ -558,6 +561,14 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendPing() {
|
func sendPing() {
|
||||||
|
//Server is not responding
|
||||||
|
if !gotPong {
|
||||||
|
pingTimer?.invalidate()
|
||||||
|
client?.engineDidClose("Ping timeout")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
gotPong = false
|
||||||
write("", withType: PacketType.PING, withData: nil)
|
write("", withType: PacketType.PING, withData: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -359,7 +359,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
_connecting = false
|
_connecting = false
|
||||||
|
|
||||||
if closed || !reconnects {
|
if closed || !reconnects {
|
||||||
didDisconnect("Engine closed")
|
didDisconnect(reason)
|
||||||
} else if !reconnecting {
|
} else if !reconnecting {
|
||||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||||
tryReconnect()
|
tryReconnect()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user