Class StatusResultListener

  • All Implemented Interfaces:
    FrameListener

    class StatusResultListener
    extends java.lang.Object
    implements FrameListener
    The StatusResultListener is used to listen for responses to ping frames sent out by the server. A response to the ping frame is a pong frame. When a pong is received it allows the session to be scheduled to receive another ping.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private StatusChecker checker
      This is used to ping sessions to check for health.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void onClose​(Session session, Reason reason)
      This is called when the connection is closed from the other side.
      void onError​(Session session, java.lang.Exception cause)
      This is called when there is an error with the connection.
      void onFrame​(Session session, Frame frame)
      This is called when a new frame arrives on the WebSocket.
      • Methods inherited from class java.lang.Object

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

      • checker

        private final StatusChecker checker
        This is used to ping sessions to check for health.
    • Constructor Detail

      • StatusResultListener

        public StatusResultListener​(StatusChecker checker)
        Constructor for the StatusResultListener object. This requires the session health checker that performs the pings so that it can reschedule the session for multiple pings if the connection responds with a pong.
        Parameters:
        checker - this is the session health checker
    • Method Detail

      • onFrame

        public void onFrame​(Session session,
                            Frame frame)
        This is called when a new frame arrives on the WebSocket. If the frame is a pong then this will reschedule the the session to receive another ping frame.
        Specified by:
        onFrame in interface FrameListener
        Parameters:
        session - this is the associated session
        frame - this is the frame that has been received
      • onError

        public void onError​(Session session,
                            java.lang.Exception cause)
        This is called when there is an error with the connection. When called the session is removed from the checker and no more ping frames are sent.
        Specified by:
        onError in interface FrameListener
        Parameters:
        session - this is the associated session
        cause - this is the cause of the error
      • onClose

        public void onClose​(Session session,
                            Reason reason)
        This is called when the connection is closed from the other side. When called the session is removed from the checker and no more ping frames are sent.
        Specified by:
        onClose in interface FrameListener
        Parameters:
        session - this is the associated session
        reason - this is the reason the connection was closed