Merge master
This commit is contained in:
commit
514193e6ec
@ -122,6 +122,7 @@ Options
|
|||||||
- `sessionDelegate: NSURLSessionDelegate` Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
|
- `sessionDelegate: NSURLSessionDelegate` Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
|
||||||
- `path: String` - If the server uses a custom path. ex: `"/swift"`. Default is `""`
|
- `path: String` - If the server uses a custom path. ex: `"/swift"`. Default is `""`
|
||||||
- `extraHeaders: [String: String]?` - Adds custom headers to the initial request. Default is nil.
|
- `extraHeaders: [String: String]?` - Adds custom headers to the initial request. Default is nil.
|
||||||
|
- `handleQueue: dispatch_queue_t` - The dispatch queue that handlers are run on. Default is the main queue.
|
||||||
|
|
||||||
Methods
|
Methods
|
||||||
-------
|
-------
|
||||||
|
|||||||
@ -51,12 +51,10 @@ struct SocketEventHandler {
|
|||||||
self.callBackObjectiveC = callback
|
self.callBackObjectiveC = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeCallback(items: [AnyObject]? = nil, withAck ack: Int? = nil, withAckType type: Int? = nil,
|
func executeCallback(items:NSArray? = nil, withAck ack:Int? = nil, withAckType type:Int? = nil,
|
||||||
withSocket socket:SocketIOClient? = nil) {
|
withSocket socket:SocketIOClient? = nil) {
|
||||||
dispatch_async(dispatch_get_main_queue()) {
|
|
||||||
self.callback != nil ?
|
self.callback != nil ?
|
||||||
self.callback?(items, emitAckCallback(socket, num: ack))
|
self.callback?(items, emitAckCallback(socket, num: ack))
|
||||||
: self.callBackObjectiveC?(items, emitAckCallbackObjectiveC(socket, num: ack))
|
: self.callBackObjectiveC?(items, emitAckCallbackObjectiveC(socket, num: ack))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
|
|
||||||
public let socketURL: String
|
public let socketURL: String
|
||||||
public let handleAckQueue = dispatch_queue_create("handleAckQueue", DISPATCH_QUEUE_SERIAL)
|
public let handleAckQueue = dispatch_queue_create("handleAckQueue", DISPATCH_QUEUE_SERIAL)
|
||||||
public let handleQueue = dispatch_queue_create("handleQueue", DISPATCH_QUEUE_SERIAL)
|
public let handleQueue: dispatch_queue_t!
|
||||||
public let emitQueue = dispatch_queue_create("emitQueue", DISPATCH_QUEUE_SERIAL)
|
public let emitQueue = dispatch_queue_create("emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||||
public var closed: Bool {
|
public var closed: Bool {
|
||||||
return _closed
|
return _closed
|
||||||
@ -111,6 +111,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
self.reconnectWait = abs(reconnectWait)
|
self.reconnectWait = abs(reconnectWait)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let handleQueue = opts?["handleQueue"] as? dispatch_queue_t {
|
||||||
|
self.handleQueue = handleQueue
|
||||||
|
} else {
|
||||||
|
self.handleQueue = dispatch_get_main_queue()
|
||||||
|
}
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,19 +379,23 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
|||||||
args: event, data ?? "")
|
args: event, data ?? "")
|
||||||
|
|
||||||
if anyHandler != nil {
|
if anyHandler != nil {
|
||||||
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
dispatch_async(handleQueue) {[weak self] in
|
||||||
self?.anyHandler?(SocketAnyEvent(event: event, items: data))
|
self?.anyHandler?(SocketAnyEvent(event: event, items: data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for handler in handlers where handler.event == event {
|
for handler in handlers where handler.event == event {
|
||||||
if ack != nil {
|
if ack != nil {
|
||||||
|
dispatch_async(handleQueue) {[weak self] in
|
||||||
handler.executeCallback(data, withAck: ack!, withSocket: self)
|
handler.executeCallback(data, withAck: ack!, withSocket: self)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
dispatch_async(handleQueue) {
|
||||||
handler.executeCallback(data)
|
handler.executeCallback(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Leaves nsp and goes back to /
|
Leaves nsp and goes back to /
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user