Skip to content

Commit

Permalink
Merge pull request #300 from Elethier/multiple-disconnects
Browse files Browse the repository at this point in the history
Added guard against multiple disconnects
  • Loading branch information
daltoniam authored Jan 11, 2017
2 parents e9160df + ddcc30d commit b22fae4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Source/WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ open class WebSocket : NSObject, StreamDelegate {
- Parameter closeCode: The code to send on disconnect. The default is the normal close code for cleanly disconnecting a webSocket.
*/
open func disconnect(forceTimeout: TimeInterval? = nil, closeCode: UInt16 = CloseCode.normal.rawValue) {
guard isConnected else { return }
switch forceTimeout {
case .some(let seconds) where seconds > 0:
let milliseconds = Int(seconds * 1_000)
Expand Down

0 comments on commit b22fae4

Please sign in to comment.