possible fix for socketio/socket.io-client-swift#279
This commit is contained in:
parent
8e208b1c66
commit
76ef3596f0
@ -378,9 +378,8 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
|
|||||||
|
|
||||||
public func open() {
|
public func open() {
|
||||||
if connected {
|
if connected {
|
||||||
DefaultSocketLogger.Logger.error("Engine tried opening while connected. This is probably a programming error. "
|
DefaultSocketLogger.Logger.error("Engine tried opening while connected. Assuming this was a reconnect", type: logType)
|
||||||
+ "Abandoning open attempt", type: logType)
|
close("reconnect")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Starting engine", type: logType)
|
DefaultSocketLogger.Logger.log("Starting engine", type: logType)
|
||||||
|
|||||||
@ -309,9 +309,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
if status == .Closed || !reconnects {
|
if status == .Closed || !reconnects {
|
||||||
didDisconnect(reason)
|
didDisconnect(reason)
|
||||||
} else if status != .Reconnecting {
|
} else if status != .Reconnecting {
|
||||||
status = .Reconnecting
|
tryReconnectWithReason(reason)
|
||||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
|
||||||
tryReconnect()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +454,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
Tries to reconnect to the server.
|
Tries to reconnect to the server.
|
||||||
*/
|
*/
|
||||||
public func reconnect() {
|
public func reconnect() {
|
||||||
tryReconnect()
|
tryReconnectWithReason("manual reconnect")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -467,9 +465,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
handlers.removeAll(keepCapacity: false)
|
handlers.removeAll(keepCapacity: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func tryReconnect() {
|
private func tryReconnectWithReason(reason: String) {
|
||||||
if reconnectTimer == nil {
|
if reconnectTimer == nil {
|
||||||
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
||||||
|
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||||
|
|
||||||
status = .Reconnecting
|
status = .Reconnecting
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user