This commit is contained in:
Erik 2016-08-28 08:29:00 -04:00
parent c7c824c3c5
commit 2200972f4d
No known key found for this signature in database
GPG Key ID: 4930B7C5FBC1A69D

View File

@ -67,7 +67,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
return nsp + "#" + (engine?.sid ?? "")
}
/// Type safe way to create a new SocketIOClient. opts can be omitted
/// Type safe way to create a new SocketIOClient. config can be omitted
public init(socketURL: NSURL, config: SocketIOClientConfiguration = []) {
self.config = config
self.socketURL = socketURL
@ -150,20 +150,21 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
dispatch_after(time, handleQueue) {[weak self] in
if let this = self where this.status != .Connected && this.status != .Disconnected {
guard let this = self where this.status != .Connected && this.status != .Disconnected else { return }
this.status = .Disconnected
this.engine?.disconnect("Connect timeout")
handler?()
}
}
}
private func createOnAck(items: [AnyObject]) -> OnAckCallback {
currentAck += 1
return {[weak self, ack = currentAck] timeout, callback in
if let this = self {
guard let this = self else { return }
dispatch_sync(this.ackQueue) {
this.ackHandlers.addAck(ack, callback: callback)
}
@ -180,7 +181,6 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
}
}
}
}
func didConnect() {
DefaultSocketLogger.Logger.log("Socket connected", type: logType)
@ -196,6 +196,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
reconnecting = false
status = .Disconnected
// Make sure the engine is actually dead.
@ -205,8 +206,6 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
/// Disconnects the socket.
public func disconnect() {
assert(status != .NotConnected, "Tried closing a NotConnected client")
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
didDisconnect("Disconnect")