@@ -40,11 +40,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
40
40
private var fastUpgrade = false
41
41
private var forcePolling = false
42
42
private var forceWebsockets = false
43
- private var pingInterval : Int ?
43
+ private var pingInterval : Double ?
44
44
private var pingTimer : NSTimer ?
45
- private var pingTimeout = 0 {
45
+ private var pingTimeout = 0.0 {
46
46
didSet {
47
- pongsMissedMax = pingTimeout / ( pingInterval ?? 25 )
47
+ pongsMissedMax = Int ( pingTimeout / ( pingInterval ?? 25 ) )
48
48
}
49
49
}
50
50
private var pongsMissed = 0
@@ -404,9 +404,9 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
404
404
createWebsocket ( andConnect: true )
405
405
}
406
406
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
410
410
}
411
411
} else {
412
412
client? . didError ( " Engine failed to handshake " )
@@ -650,8 +650,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
650
650
pingTimer? . invalidate ( )
651
651
dispatch_async ( dispatch_get_main_queue ( ) ) { [ weak self] in
652
652
if let this = self {
653
- this. pingTimer = NSTimer . scheduledTimerWithTimeInterval ( NSTimeInterval ( this. pingInterval!) ,
654
- target: this,
653
+ this. pingTimer = NSTimer . scheduledTimerWithTimeInterval ( this. pingInterval!, target: this,
655
654
selector: Selector ( " sendPing " ) , userInfo: nil , repeats: true )
656
655
}
657
656
}
0 commit comments