@@ -40,11 +40,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
4040 private var fastUpgrade = false
4141 private var forcePolling = false
4242 private var forceWebsockets = false
43- private var pingInterval : Int ?
43+ private var pingInterval : Double ?
4444 private var pingTimer : NSTimer ?
45- private var pingTimeout = 0 {
45+ private var pingTimeout = 0.0 {
4646 didSet {
47- pongsMissedMax = pingTimeout / ( pingInterval ?? 25 )
47+ pongsMissedMax = Int ( pingTimeout / ( pingInterval ?? 25 ) )
4848 }
4949 }
5050 private var pongsMissed = 0
@@ -404,9 +404,9 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
404404 createWebsocket ( andConnect: true )
405405 }
406406
407- if let pingInterval = json [ " pingInterval " ] as? Int , pingTimeout = json [ " pingTimeout " ] as? Int {
408- self . pingInterval = pingInterval / 1000
409- self . pingTimeout = pingTimeout / 1000
407+ if let pingInterval = json [ " pingInterval " ] as? Double , pingTimeout = json [ " pingTimeout " ] as? Double {
408+ self . pingInterval = pingInterval / 1000.0
409+ self . pingTimeout = pingTimeout / 1000.0
410410 }
411411 } else {
412412 client? . didError ( " Engine failed to handshake " )
@@ -650,8 +650,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
650650 pingTimer? . invalidate ( )
651651 dispatch_async ( dispatch_get_main_queue ( ) ) { [ weak self] in
652652 if let this = self {
653- this. pingTimer = NSTimer . scheduledTimerWithTimeInterval ( NSTimeInterval ( this. pingInterval!) ,
654- target: this,
653+ this. pingTimer = NSTimer . scheduledTimerWithTimeInterval ( this. pingInterval!, target: this,
655654 selector: Selector ( " sendPing " ) , userInfo: nil , repeats: true )
656655 }
657656 }
0 commit comments