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() {
|
||||
if connected {
|
||||
DefaultSocketLogger.Logger.error("Engine tried opening while connected. This is probably a programming error. "
|
||||
+ "Abandoning open attempt", type: logType)
|
||||
return
|
||||
DefaultSocketLogger.Logger.error("Engine tried opening while connected. Assuming this was a reconnect", type: logType)
|
||||
close("reconnect")
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Starting engine", type: logType)
|
||||
|
||||
@ -309,9 +309,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
||||
if status == .Closed || !reconnects {
|
||||
didDisconnect(reason)
|
||||
} else if status != .Reconnecting {
|
||||
status = .Reconnecting
|
||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||
tryReconnect()
|
||||
tryReconnectWithReason(reason)
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,7 +454,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
||||
Tries to reconnect to the server.
|
||||
*/
|
||||
public func reconnect() {
|
||||
tryReconnect()
|
||||
tryReconnectWithReason("manual reconnect")
|
||||
}
|
||||
|
||||
/**
|
||||
@ -467,9 +465,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
||||
handlers.removeAll(keepCapacity: false)
|
||||
}
|
||||
|
||||
private func tryReconnect() {
|
||||
private func tryReconnectWithReason(reason: String) {
|
||||
if reconnectTimer == nil {
|
||||
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||
|
||||
status = .Reconnecting
|
||||
|
||||
|
||||
@ -65,4 +65,4 @@ struct SocketStringReader {
|
||||
mutating func readUntilEnd() -> String {
|
||||
return read(currentIndex.distanceTo(message.endIndex))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user