clean up
This commit is contained in:
parent
fdfd4dbc4d
commit
88c139ed0c
@ -493,15 +493,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
} else if type == PacketType.NOOP {
|
||||
self.doPoll()
|
||||
return
|
||||
} else if type == PacketType.PONG {
|
||||
// We should upgrade
|
||||
if message == "3probe" {
|
||||
self.upgradeTransport()
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
} else if type == PacketType.OPEN {
|
||||
var err:NSError?
|
||||
|
||||
@ -531,8 +527,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
if !self.forceWebsockets {
|
||||
self.doPoll()
|
||||
}
|
||||
|
||||
return
|
||||
} else if type == PacketType.CLOSE {
|
||||
if self.client == nil {
|
||||
return
|
||||
@ -541,8 +535,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
if self.polling {
|
||||
self.client!.engineDidClose("Disconnect")
|
||||
}
|
||||
|
||||
return
|
||||
} else if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||
|
||||
@ -89,16 +89,15 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
self.opts = opts
|
||||
|
||||
// Set options
|
||||
if opts != nil {
|
||||
if let sessionDelegate = opts!["sessionDelegate"] as? NSURLSessionDelegate {
|
||||
if let sessionDelegate = opts?["sessionDelegate"] as? NSURLSessionDelegate {
|
||||
self.sessionDelegate = sessionDelegate
|
||||
}
|
||||
|
||||
if let log = opts!["log"] as? Bool {
|
||||
if let log = opts?["log"] as? Bool {
|
||||
self.log = log
|
||||
}
|
||||
|
||||
if var nsp = opts!["nsp"] as? String {
|
||||
if var nsp = opts?["nsp"] as? String {
|
||||
if nsp != "/" && nsp.hasPrefix("/") {
|
||||
nsp.removeAtIndex(nsp.startIndex)
|
||||
}
|
||||
@ -106,22 +105,19 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
self.nsp = nsp
|
||||
}
|
||||
|
||||
if let reconnects = opts!["reconnects"] as? Bool {
|
||||
if let reconnects = opts?["reconnects"] as? Bool {
|
||||
self.reconnects = reconnects
|
||||
}
|
||||
|
||||
if let reconnectAttempts = opts!["reconnectAttempts"] as? Int {
|
||||
if let reconnectAttempts = opts?["reconnectAttempts"] as? Int {
|
||||
self.reconnectAttempts = reconnectAttempts
|
||||
} else {
|
||||
self.reconnectAttempts = -1
|
||||
}
|
||||
|
||||
if let reconnectWait = opts!["reconnectWait"] as? Int {
|
||||
if let reconnectWait = opts?["reconnectWait"] as? Int {
|
||||
self.reconnectWait = abs(reconnectWait)
|
||||
}
|
||||
} else {
|
||||
self.reconnectAttempts = -1
|
||||
}
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
@ -94,7 +94,6 @@ final class SocketPacket: Printable {
|
||||
|
||||
func createMessageForEvent(event:String) -> String {
|
||||
let message:String
|
||||
var jsonSendError:NSError?
|
||||
|
||||
if self.binary.count == 0 {
|
||||
self.type = PacketType.EVENT
|
||||
@ -157,7 +156,7 @@ final class SocketPacket: Printable {
|
||||
return self.completeMessage(msg, ack: true)
|
||||
}
|
||||
|
||||
func completeMessage(var message:String, ack:Bool = false) -> String {
|
||||
private func completeMessage(var message:String, ack:Bool = false) -> String {
|
||||
var err:NSError?
|
||||
|
||||
if self.data == nil || self.data!.count == 0 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user