This commit is contained in:
parent
7a1a0d91f9
commit
90bbc9521f
@ -195,21 +195,19 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
|
|
||||||
private func createOnAck(event:String, items:[AnyObject]) -> OnAckCallback {
|
private func createOnAck(event:String, items:[AnyObject]) -> OnAckCallback {
|
||||||
return {[weak self, ack = ++self.currentAck] timeout, callback in
|
return {[weak self, ack = ++self.currentAck] timeout, callback in
|
||||||
if self == nil {
|
if let this = self {
|
||||||
return
|
this.ackHandlers.addAck(ack, callback: callback)
|
||||||
}
|
|
||||||
|
|
||||||
self?.ackHandlers.addAck(ack, callback: callback)
|
|
||||||
|
|
||||||
dispatch_async(self!.emitQueue) {
|
|
||||||
self?._emit(event, items, ack: ack)
|
|
||||||
}
|
|
||||||
|
|
||||||
if timeout != 0 {
|
|
||||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
|
||||||
|
|
||||||
dispatch_after(time, dispatch_get_main_queue()) {
|
dispatch_async(this.emitQueue) {[weak this] in
|
||||||
self?.ackHandlers.timeoutAck(ack)
|
this?._emit(event, items, ack: ack)
|
||||||
|
}
|
||||||
|
|
||||||
|
if timeout != 0 {
|
||||||
|
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||||
|
|
||||||
|
dispatch_after(time, dispatch_get_main_queue()) {[weak this] in
|
||||||
|
this?.ackHandlers.timeoutAck(ack)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,22 +335,21 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
// If the server wants to know that the client received data
|
// If the server wants to know that the client received data
|
||||||
func emitAck(ack:Int, withData args:[AnyObject]) {
|
func emitAck(ack:Int, withData args:[AnyObject]) {
|
||||||
dispatch_async(self.emitQueue) {[weak self] in
|
dispatch_async(self.emitQueue) {[weak self] in
|
||||||
if self == nil || !self!.connected {
|
if let this = self where this.connected {
|
||||||
return
|
let packet = SocketPacket(type: nil, data: args, nsp: this.nsp, id: ack)
|
||||||
}
|
let str:String
|
||||||
|
|
||||||
let packet = SocketPacket(type: nil, data: args, nsp: self!.nsp, id: ack)
|
SocketParser.parseForEmit(packet)
|
||||||
let str:String
|
str = packet.createAck()
|
||||||
|
|
||||||
SocketParser.parseForEmit(packet)
|
SocketLogger.log("Emitting Ack: \(str)", client: this)
|
||||||
str = packet.createAck()
|
|
||||||
|
if packet.type == SocketPacket.PacketType.BINARY_ACK {
|
||||||
SocketLogger.log("Emitting Ack: \(str)", client: self!)
|
this.engine?.send(str, withData: packet.binary)
|
||||||
|
} else {
|
||||||
if packet.type == SocketPacket.PacketType.BINARY_ACK {
|
this.engine?.send(str, withData: nil)
|
||||||
self?.engine?.send(str, withData: packet.binary)
|
}
|
||||||
} else {
|
|
||||||
self?.engine?.send(str, withData: nil)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -484,12 +481,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
self._reconnecting = true
|
self._reconnecting = true
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
||||||
if self == nil {
|
if let this = self {
|
||||||
return
|
this.reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(Double(this.reconnectWait),
|
||||||
|
target: this, selector: "tryReconnect", userInfo: nil, repeats: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
self?.reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(Double(self!.reconnectWait),
|
|
||||||
target: self!, selector: "tryReconnect", userInfo: nil, repeats: true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user