This commit is contained in:
Erik 2015-04-22 15:26:34 -04:00
parent eab7311037
commit 922ed4b575
2 changed files with 55 additions and 56 deletions

View File

@ -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,10 +541,8 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
}
return
} else {
if message.hasPrefix("b4") {
} else if message.hasPrefix("b4") {
// binary in base64 string
message.removeRange(Range<String.Index>(start: message.startIndex,
end: advance(message.startIndex, 2)))
@ -558,7 +557,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
}
}
}
}
private func probeWebSocket() {
if self.websocketConnected {

View File

@ -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() {
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])
}