File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,20 @@ extension PusherConnection: WebSocketDelegate {
31
31
- parameter error: The error, if one exists, when disconnected
32
32
*/
33
33
public func websocketDidDisconnect( ws: WebSocket , error: NSError ? ) {
34
- if let error = error {
35
- print ( " Websocket is disconnected: \( error. localizedDescription) " )
36
- }
37
34
38
35
updateConnectionState ( . Disconnected)
39
36
for (_, channel) in self . channels. channels {
40
37
channel. subscribed = false
41
38
}
42
-
39
+
40
+ // Handle error (if any)
41
+ guard let error = error else {
42
+ return
43
+ }
44
+
45
+ print ( " Websocket is disconnected. Error: \( error. localizedDescription) " )
46
+
47
+ // Reconnect if possible
43
48
if let reconnect = self . options. autoReconnect where reconnect {
44
49
if let reachability = self . reachability where reachability. isReachable ( ) {
45
50
let operation = NSBlockOperation {
You can’t perform that action at this time.
0 commit comments