use new if let

This commit is contained in:
Erik 2015-04-09 01:01:14 -04:00
parent a01e85ba05
commit 67c41c0107

View File

@ -479,24 +479,21 @@ public class SocketEngine: NSObject, WebSocketDelegate {
let mesData = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! let mesData = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
if let json = NSJSONSerialization.JSONObjectWithData(mesData, if let json = NSJSONSerialization.JSONObjectWithData(mesData,
options: NSJSONReadingOptions.AllowFragments, error: &err) as? NSDictionary { options: NSJSONReadingOptions.AllowFragments, error: &err) as? NSDictionary,
if let sid = json["sid"] as? String { let sid = json["sid"] as? String {
// println(json) self.sid = sid
self.sid = sid self._connected = true
self._connected = true
if !self.forcePolling && !self.forceWebsockets { if !self.forcePolling && !self.forceWebsockets {
self.createWebsocket(andConnect: true) self.createWebsocket(andConnect: true)
}
} else {
NSLog("Error handshaking")
return
} }
if let pingInterval = json["pingInterval"] as? Int { if let pingInterval = json["pingInterval"] as? Int {
self.pingInterval = pingInterval / 1000 self.pingInterval = pingInterval / 1000
} }
} else { } else {
fatalError("Error parsing engine connect") self.client?.engineDidError("Engine failed to handshake")
return
} }
self.startPingTimer() self.startPingTimer()