Interface WsListener


public interface WsListener
WebSocket listener.
  • Method Details

    • onMessage

      default void onMessage(WsSession session, String text, boolean last)
      Received text fragment.
      Parameters:
      session - WebSocket session
      text - text received
      last - is this last fragment
    • onMessage

      default void onMessage(WsSession session, BufferData buffer, boolean last)
      Received binary fragment.
      Parameters:
      session - WebSocket session
      buffer - buffer with data
      last - is this last fragment
    • onPing

      default void onPing(WsSession session, BufferData buffer)
      Received ping.
      Parameters:
      session - WebSocket session
      buffer - buffer with data
    • onPong

      default void onPong(WsSession session, BufferData buffer)
      Received pong.
      Parameters:
      session - WebSocket session
      buffer - buffer with data
    • onClose

      default void onClose(WsSession session, int status, String reason)
      Received close.
      Parameters:
      session - WebSocket session
      status - close status
      reason - reason of close
    • onError

      default void onError(WsSession session, Throwable t)
      Error occurred.
      Parameters:
      session - WebSocket session
      t - throwable caught
    • onOpen

      default void onOpen(WsSession session)
      Session is open.
      Parameters:
      session - WebSocket session
    • onHttpUpgrade

      default Optional<Headers> onHttpUpgrade(HttpPrologue prologue, Headers headers) throws WsUpgradeException
      Invoked during handshake process. Can be used to negotiate sub-protocols and/or reject an upgrade by throwing WsUpgradeException.
      Parameters:
      prologue - the http handshake request
      headers - headers in request
      Returns:
      headers to be included in handshake response
      Throws:
      WsUpgradeException - if handshake is rejected