Add isBinary property to SocketPacket.PacketType
This commit is contained in:
parent
35c93ee6f5
commit
165ec25713
@ -392,7 +392,7 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
|
||||
|
||||
private func _parseEngineMessage(_ msg: String) {
|
||||
guard let packet = parseSocketMessage(msg) else { return }
|
||||
guard packet.type != .binaryAck && packet.type != .binaryEvent else {
|
||||
guard !packet.type.isBinary else {
|
||||
waitingPackets.append(packet)
|
||||
|
||||
return
|
||||
|
||||
@ -116,7 +116,7 @@ public struct SocketPacket : CustomStringConvertible {
|
||||
private func createPacketString() -> String {
|
||||
let typeString = String(type.rawValue)
|
||||
// Binary count?
|
||||
let binaryCountString = typeString + (type == .binaryEvent || type == .binaryAck ? "\(String(binary.count))-" : "")
|
||||
let binaryCountString = typeString + (type.isBinary ? "\(String(binary.count))-" : "")
|
||||
// Namespace?
|
||||
let nspString = binaryCountString + (nsp != "/" ? "\(nsp)," : "")
|
||||
// Ack number?
|
||||
@ -181,6 +181,13 @@ public extension SocketPacket {
|
||||
|
||||
/// Binary Ack: 6
|
||||
case binaryAck
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// Whether or not this type is binary
|
||||
public var isBinary: Bool {
|
||||
return self == .binaryAck || self == .binaryEvent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer
|
||||
var namespace = "/"
|
||||
var placeholders = -1
|
||||
|
||||
if type == .binaryEvent || type == .binaryAck {
|
||||
if type.isBinary {
|
||||
if let holders = Int(reader.readUntilOccurence(of: "-")) {
|
||||
placeholders = holders
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user