This commit is contained in:
parent
eab7311037
commit
922ed4b575
@ -39,6 +39,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
private let parseQueue = dispatch_queue_create("engineParseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let handleQueue = dispatch_queue_create("engineHandleQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let session:NSURLSession!
|
||||
|
||||
private var closed = false
|
||||
private var _connected = false
|
||||
private var fastUpgrade = false
|
||||
@ -540,22 +541,19 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
return
|
||||
} else {
|
||||
if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
} else if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||
end: advance(message.startIndex, 2)))
|
||||
|
||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||
end: advance(message.startIndex, 2)))
|
||||
if let data = NSData(base64EncodedString: message,
|
||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
|
||||
where self.client != nil {
|
||||
// println("sending \(data)")
|
||||
|
||||
if let data = NSData(base64EncodedString: message,
|
||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
|
||||
where self.client != nil {
|
||||
// println("sending \(data)")
|
||||
|
||||
dispatch_async(self.client!.handleQueue) {[weak self] in
|
||||
self?.client?.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
dispatch_async(self.client!.handleQueue) {[weak self] in
|
||||
self?.client?.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,6 +175,9 @@ final class SocketPacket: Printable {
|
||||
message += jsonString! as String
|
||||
message += ","
|
||||
continue
|
||||
} else if arg is NSNull {
|
||||
message += "null,"
|
||||
continue
|
||||
}
|
||||
|
||||
if arg is String {
|
||||
@ -198,10 +201,8 @@ final class SocketPacket: Printable {
|
||||
var newArr = NSMutableArray(array: self.data!)
|
||||
|
||||
for i in 0..<self.data!.count {
|
||||
if let str = self.data?[i] as? String {
|
||||
if let num = str["~~(\\d)"].groups() {
|
||||
newArr[i] = self.binary[num[1].toInt()!]
|
||||
}
|
||||
if let str = self.data?[i] as? String, num = str["~~(\\d)"].groups() {
|
||||
newArr[i] = self.binary[num[1].toInt()!]
|
||||
} else if self.data?[i] is NSDictionary || self.data?[i] is NSArray {
|
||||
newArr[i] = self._fillInPlaceholders(self.data![i])
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user