Interface SocketListener


public interface SocketListener
Receives messages as they come in from the sockets. Also notified on other important socket events.

None of the messages will be triggered concurrently on this listener; however, different listeners may be notified in parallel. This means, for example, that onClose will not happen while onMessages is being invoked.

The given socket will always represent the current state, while the events are delivered in-order. Thus, newRemoteSocketAddress may not necessarily be the same as the HttpSocket.getMostRecentRemoteSocketAddress.

  • Method Details

    • onMessages

      void onMessages(Socket socket, List<? extends Message> messages)
      Called when one or more new messages arrive. Messages are always delivered in-order. At least one message will be provided. Subsequent messages will not be sent until this onMessage completes.
      Parameters:
      messages - The unmodifiable list of messages in the order received
    • onError

      void onError(Socket socket, Throwable t)
      Called when an error occurs. The socket is closed after the first error.
    • onRemoteSocketAddressChange

      void onRemoteSocketAddressChange(Socket socket, SocketAddress oldRemoteSocketAddress, SocketAddress newRemoteSocketAddress)
      Called when a new remote address is seen.
    • onSocketClose

      void onSocketClose(Socket socket)
      Called when a socket is closed. This will only be called once.