Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Add cases for network viablity changed, reconnect suggested, and canc…
Browse files Browse the repository at this point in the history
…elled. (#250)
  • Loading branch information
tmg-mlyons authored Sep 21, 2021
1 parent 4fb87cb commit e8cfb4d
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions Sources/ParseLiveQuery/Internal/ClientPrivate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,32 @@ extension Client: WebSocketDelegate {
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received binary data but we don't handle it...") }
case .error(let error):
NSLog("ParseLiveQuery: Error processing message: \(String(describing: error))")
default:
break
case .viabilityChanged(let isViable):
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket viability channged to \(isViable ? "" : "not-")viable") }
if !isViable {
isConnecting = false
}
// TODO: Better retry logic, unless `disconnect()` was explicitly called
if !userDisconnected, isViable {
reconnect()
}
case .reconnectSuggested(let isSuggested):
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket reconnect is \(isSuggested ? "" : "not ")suggested") }
// TODO: Better retry logic, unless `disconnect()` was explicitly called
if !userDisconnected, isSuggested {
reconnect()
}
case .cancelled:
isConnecting = false
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket connection cancelled...") }
// TODO: Better retry logic, unless `disconnect()` was explicitly called
if !userDisconnected {
reconnect()
}
case .pong(_):
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received pong but we don't handle it...") }
case .ping(_):
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received ping but we don't handle it...") }
}
}
}
Expand Down

0 comments on commit e8cfb4d

Please sign in to comment.