Fix binary acks

This commit is contained in:
Erik 2015-03-27 12:13:06 -04:00
parent 98e0c355f9
commit ffcd841267
4 changed files with 12 additions and 10 deletions

View File

@ -460,17 +460,17 @@ public class SocketEngine: NSObject, WebSocketDelegate {
if let pingInterval = json["pingInterval"] as? Int {
self.pingInterval = pingInterval / 1000
}
}
} else {
fatalError("Error parsing engine connect")
}
self.startPingTimer()
if !self.forceWebsockets {
self.doPoll()
}
self.startPingTimer()
return
} else if type == PacketType.CLOSE.rawValue {
if self.polling {

View File

@ -348,7 +348,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
Causes an event to be handled. Only use if you know what you're doing.
*/
public func handleEvent(event:String, data:[AnyObject]?, isInternalMessage:Bool = false,
wantsAck ack:Int? = nil, withAckType ackType:Int = 3) {
wantsAck ack:Int? = nil) {
// println("Should do event: \(event) with data: \(data)")
if !self.connected && !isInternalMessage {
return
@ -364,8 +364,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
for handler in self.handlers {
if handler.event == event {
if ack != nil {
handler.executeCallback(data, withAck: ack!,
withAckType: ackType, withSocket: self)
handler.executeCallback(data, withAck: ack!, withSocket: self)
} else {
handler.executeCallback(data)
}

View File

@ -134,12 +134,16 @@ class SocketPacket {
var msg:String
if self.binary.count == 0 {
self.type = SocketPacketType.ACK
if nsp == "/" {
msg = "3\(self.id!)["
} else {
msg = "3/\(self.nsp),\(self.id!)["
}
} else {
self.type = SocketPacketType.BINARY_ACK
if nsp == "/" {
msg = "6\(self.binary.count)-\(self.id!)["
} else {
@ -195,8 +199,6 @@ class SocketPacket {
if let str = self.data?[i] as? String {
if let num = str["~~(\\d)"].groups() {
newArr[i] = self.binary[num[1].toInt()!]
} else {
newArr[i] = str
}
} else if self.data?[i] is NSDictionary || self.data?[i] is NSArray {
newArr[i] = self._fillInPlaceholders(self.data![i])

View File

@ -197,7 +197,8 @@ class SocketParser {
return
}
socket.handleEvent(p.getEvent(), data: p.data, isInternalMessage: false, wantsAck: p.id, withAckType: 3)
socket.handleEvent(p.getEvent(), data: p.data, isInternalMessage: false,
wantsAck: p.id)
} else if p.type == SocketPacketType.ACK {
if checkNSP(p.nsp) {
return
@ -250,7 +251,7 @@ class SocketParser {
if !packet.justAck {
socket.handleEvent(packet.getEvent(), data: packet.data,
wantsAck: packet.id, withAckType: 6)
wantsAck: packet.id)
} else {
socket.handleAck(packet.id!, data: packet.data)
}