add no timeout
This commit is contained in:
parent
d75457f397
commit
2022f282c9
@ -103,7 +103,8 @@ socket.on("ackEvent") {data, ack in
|
||||
println("Got int")
|
||||
}
|
||||
|
||||
socket.emitWithAck("ackTest", "test").onAck {data in
|
||||
// You can specify a custom timeout interval. 0 means no timeout.
|
||||
socket.emitWithAck("ackTest", "test").onAck(0) {data in
|
||||
println(data?[0])
|
||||
}
|
||||
|
||||
|
||||
@ -40,14 +40,17 @@ public typealias AckCallback = (NSArray?) -> Void
|
||||
public func onAck(timeout:UInt64, withCallback callback:AckCallback) {
|
||||
self.callback = callback
|
||||
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||
dispatch_after(time, dispatch_get_main_queue()) {[weak self] in
|
||||
if self == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !self!.acked {
|
||||
self?.executeAck(["No ACK"])
|
||||
if timeout != 0 {
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||
dispatch_after(time, dispatch_get_main_queue()) {[weak self] in
|
||||
if self == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !self!.acked {
|
||||
self?.executeAck(["No ACK"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,6 +396,7 @@ public class SocketIOClient: NSObject {
|
||||
|
||||
if self.reconnectTimer == nil {
|
||||
self._reconnecting = true
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
||||
if self == nil {
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user