Package io.deephaven.web.client.api
Class ReconnectState
java.lang.Object
io.deephaven.web.client.api.ReconnectState
Util class using exponential backoff to keep trying to connect to a server. Any disconnect should call failed(), and
the given retry callback will be invoked as appropriate. Once connection is established, success() should be invoked
to clear the reset tries attempted.
Max backoff is doubled each failure, to a max of one minute. A random value between 0 and that backoff is selected to
wait before trying again, to avoid clients all attempting to simultaneously reconnect.
A maximum number of times to try can be specified, otherwise defaults to MAX_VALUE.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionReconnectState
(int maxTries, JsRunnable retry) ReconnectState
(JsRunnable retry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
After the connection has been deliberately closed, call this to prepare for a later connection.void
failed()
After the connection closes or attempt fails, should be called.getState()
void
Call once it is time to connect for the first time, will invoke the retry function.void
success()
After a successful connection is established, should be called.
-
Constructor Details
-
Method Details
-
initialConnection
public void initialConnection()Call once it is time to connect for the first time, will invoke the retry function. Can also be called after failure to start trying to connect fresh. -
success
public void success()After a successful connection is established, should be called. -
failed
public void failed()After the connection closes or attempt fails, should be called. -
disconnected
public void disconnected()After the connection has been deliberately closed, call this to prepare for a later connection. -
getState
-