You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -206,6 +206,16 @@ class ViewController: UIViewController, ConnectionStateChangeDelegate {
206
206
}
207
207
```
208
208
209
+
The different states that the connection can be in are:
210
+
211
+
*`Connecting` - the connection is about to attempt to be made
212
+
*`Connected` - the connection has been successfully made
213
+
*`Disconnecting` - the connection has been instructed to disconnect and it is just about to do so
214
+
*`Disconnected` - the connection has disconnected and no attempt will be made to reconnect automatically
215
+
*`Reconnecting` - an attempt is going to be made to try and re-establish the connection
216
+
*`ReconnectingWhenNetworkBecomesReachable` - when the network becomes reachable an attempt will be made to reconnect
217
+
218
+
209
219
### Reconnection
210
220
211
221
There are three main ways in which a disconnection can occur:
@@ -222,6 +232,12 @@ If the Pusher servers close the websocket then the library will attempt to recon
222
232
223
233
All of this is the case if you have the client option of `autoReconnect` set as `true`, which it is by default. If the reconnection strategies are not suitable for your use case then you can set `autoReconnect` to `false` and implement your own reconnection strategy based on the connection state changes.
224
234
235
+
There are a couple of properties on the connection (`PusherConnection`) that you can set that affect how the reconnection behaviour works. These are:
236
+
237
+
*`public var reconnectAttemptsMax: Int? = 6` - if you set this to `nil` then there is no maximum number of reconnect attempts and so attempts will continue to be made with an exponential backoff (based on number of attempts), otherwise only as many attempts as this property's value will be made before the connection's state moves to `.Disconnected`
238
+
*`public var maxReconnectGapInSeconds: Double? = nil` - if you want to set a maximum length of time (in seconds) between reconnect attempts then set this property appropriately
239
+
240
+
Note that the number of reconnect attempts gets reset to 0 as soon as a successful connection is made.
0 commit comments