Class ReconnectState

java.lang.Object
io.deephaven.web.client.api.ReconnectState

public class ReconnectState extends Object
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.
  • Constructor Details

    • ReconnectState

      public ReconnectState(JsRunnable retry)
    • ReconnectState

      public ReconnectState(int maxTries, JsRunnable retry)
  • 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

      public ReconnectState.State getState()