Refactor engine. Fix infinite recursion in configuration
This commit is contained in:
parent
4de7a48e87
commit
bd7f94333d
@ -359,36 +359,38 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo
|
|||||||
private func handleOpen(openData: String) {
|
private func handleOpen(openData: String) {
|
||||||
do {
|
do {
|
||||||
let json = try openData.toNSDictionary()
|
let json = try openData.toNSDictionary()
|
||||||
|
guard let sid = json[sid] as? String else {
|
||||||
if let sid = json["sid"] as? String {
|
client?.engineDidError("Open packet contained no sid")
|
||||||
let upgradeWs: Bool
|
return
|
||||||
|
|
||||||
self.sid = sid
|
|
||||||
connected = true
|
|
||||||
|
|
||||||
if let upgrades = json["upgrades"] as? [String] {
|
|
||||||
upgradeWs = upgrades.contains("websocket")
|
|
||||||
} else {
|
|
||||||
upgradeWs = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double {
|
|
||||||
self.pingInterval = pingInterval / 1000.0
|
|
||||||
self.pingTimeout = pingTimeout / 1000.0
|
|
||||||
}
|
|
||||||
|
|
||||||
if !forcePolling && !forceWebsockets && upgradeWs {
|
|
||||||
createWebsocketAndConnect()
|
|
||||||
}
|
|
||||||
|
|
||||||
sendPing()
|
|
||||||
|
|
||||||
if !forceWebsockets {
|
|
||||||
doPoll()
|
|
||||||
}
|
|
||||||
|
|
||||||
client?.engineDidOpen("Connect")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let upgradeWs: Bool
|
||||||
|
|
||||||
|
self.sid = sid
|
||||||
|
connected = true
|
||||||
|
|
||||||
|
if let upgrades = json["upgrades"] as? [String] {
|
||||||
|
upgradeWs = upgrades.contains("websocket")
|
||||||
|
} else {
|
||||||
|
upgradeWs = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double {
|
||||||
|
self.pingInterval = pingInterval / 1000.0
|
||||||
|
self.pingTimeout = pingTimeout / 1000.0
|
||||||
|
}
|
||||||
|
|
||||||
|
if !forcePolling && !forceWebsockets && upgradeWs {
|
||||||
|
createWebsocketAndConnect()
|
||||||
|
}
|
||||||
|
|
||||||
|
sendPing()
|
||||||
|
|
||||||
|
if !forceWebsockets {
|
||||||
|
doPoll()
|
||||||
|
}
|
||||||
|
|
||||||
|
client?.engineDidOpen("Connect")
|
||||||
} catch {
|
} catch {
|
||||||
didError("Error parsing open packet")
|
didError("Error parsing open packet")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public struct SocketIOClientConfiguration : ArrayLiteralConvertible, CollectionT
|
|||||||
|
|
||||||
@warn_unused_result
|
@warn_unused_result
|
||||||
public func prefixThrough(position: Index) -> SubSequence {
|
public func prefixThrough(position: Index) -> SubSequence {
|
||||||
return prefixThrough(position)
|
return backingArray.prefixThrough(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
@warn_unused_result
|
@warn_unused_result
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user