Changed 'timeoutAfter' from Int to Double to allow more precise value

This commit is contained in:
mathieurobidoux 2017-06-25 13:13:32 -04:00
parent b86e78797e
commit 38dea9bb3e

View File

@ -169,7 +169,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
/// - parameter timeoutAfter: The number of seconds after which if we are not connected we assume the connection /// - parameter timeoutAfter: The number of seconds after which if we are not connected we assume the connection
/// has failed. Pass 0 to never timeout. /// has failed. Pass 0 to never timeout.
/// - parameter withHandler: The handler to call when the client fails to connect. /// - parameter withHandler: The handler to call when the client fails to connect.
open func connect(timeoutAfter: Int, withHandler handler: (() -> ())?) { open func connect(timeoutAfter: Double, withHandler handler: (() -> ())?) {
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)") assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
guard status != .connected else { guard status != .connected else {
@ -187,7 +187,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
guard timeoutAfter != 0 else { return } guard timeoutAfter != 0 else { return }
handleQueue.asyncAfter(deadline: DispatchTime.now() + Double(timeoutAfter)) {[weak self] in handleQueue.asyncAfter(deadline: DispatchTime.now() + timeoutAfter) {[weak self] in
guard let this = self, this.status == .connecting || this.status == .notConnected else { return } guard let this = self, this.status == .connecting || this.status == .notConnected else { return }
this.status = .disconnected this.status = .disconnected