create write method that can be used from objc
This commit is contained in:
parent
7c0c12ba0c
commit
eab7311037
@ -646,6 +646,9 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Write a message, independent of transport.
|
||||
*/
|
||||
public func write(msg:String, withType type:PacketType, withData data:ContiguousArray<NSData>?) {
|
||||
dispatch_async(self.emitQueue) {[weak self] in
|
||||
if self == nil || !self!.connected {
|
||||
@ -662,6 +665,23 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Write a message, independent of transport. For Objective-C. withData should be an NSArray of NSData
|
||||
*/
|
||||
public func writeObjc(msg:String, withType type:Int, withData data:NSArray?) {
|
||||
if let pType = PacketType(rawValue: type) {
|
||||
var arr = ContiguousArray<NSData>()
|
||||
|
||||
if data != nil {
|
||||
for d in data! {
|
||||
arr.append(d as! NSData)
|
||||
}
|
||||
}
|
||||
|
||||
self.write(msg, withType: pType, withData: arr)
|
||||
}
|
||||
}
|
||||
|
||||
// Delagate methods
|
||||
|
||||
public func websocketDidConnect(socket:WebSocket) {
|
||||
|
||||
@ -490,7 +490,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
|
||||
self?.reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(Double(self!.reconnectWait),
|
||||
target: self!, selector: "tryReconnect", userInfo: nil, repeats: true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user