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")
|
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])
|
println(data?[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,8 @@ public typealias AckCallback = (NSArray?) -> Void
|
|||||||
public func onAck(timeout:UInt64, withCallback callback:AckCallback) {
|
public func onAck(timeout:UInt64, withCallback callback:AckCallback) {
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
|
|
||||||
|
|
||||||
|
if timeout != 0 {
|
||||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||||
dispatch_after(time, dispatch_get_main_queue()) {[weak self] in
|
dispatch_after(time, dispatch_get_main_queue()) {[weak self] in
|
||||||
if self == nil {
|
if self == nil {
|
||||||
@ -51,6 +53,7 @@ public typealias AckCallback = (NSArray?) -> Void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func executeAck(data:NSArray?) {
|
func executeAck(data:NSArray?) {
|
||||||
dispatch_async(dispatch_get_main_queue()) {[weak self, cb = self.callback] in
|
dispatch_async(dispatch_get_main_queue()) {[weak self, cb = self.callback] in
|
||||||
|
|||||||
@ -396,6 +396,7 @@ public class SocketIOClient: NSObject {
|
|||||||
|
|
||||||
if self.reconnectTimer == nil {
|
if self.reconnectTimer == nil {
|
||||||
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 self == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user