Class ClientManager.ReconnectHandler

  • Enclosing class:
    ClientManager

    public static class ClientManager.ReconnectHandler
    extends java.lang.Object
    Reconnect handler.

    When implementing, be sure that you do have enough logic behind cancelling reconnect feature - even Session.close() call will be treated just like any other disconnect resulting in reconnect.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getDelay()
      Get reconnect delay.
      boolean onConnectFailure​(java.lang.Exception exception)
      Called when there is a connection failure.
      boolean onDisconnect​(jakarta.websocket.CloseReason closeReason)
      Called after OnClose annotated method (or Endpoint.onClose(jakarta.websocket.Session, jakarta.websocket.CloseReason) is invoked.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReconnectHandler

        public ReconnectHandler()
    • Method Detail

      • onDisconnect

        public boolean onDisconnect​(jakarta.websocket.CloseReason closeReason)
        Called after OnClose annotated method (or Endpoint.onClose(jakarta.websocket.Session, jakarta.websocket.CloseReason) is invoked.
        Parameters:
        closeReason - close reason passed to onClose method.
        Returns:
        When true is returned, client container will reconnect.
      • onConnectFailure

        public boolean onConnectFailure​(java.lang.Exception exception)
        Called when there is a connection failure.

        Type of the failure is indicated by Exception parameter. Be cautious when implementing this method, you might easily cause DDoS like behaviour.

        Parameters:
        exception - Exception thrown during connection phase.
        Returns:
        When true is returned, client container will reconnect.
      • getDelay

        public long getDelay()
        Get reconnect delay.

        Called after onDisconnect(CloseReason) or onConnectFailure(Exception) when true is returned. When positive value is returned, next connection attempt will be made after that number of seconds.

        Default implementation returns 5L.

        Returns:
        reconnect delay in seconds.