Class EndpointAdapter

  • All Implemented Interfaces:
    Endpoint

    public abstract class EndpointAdapter
    extends Object
    implements Endpoint
    An Endpoint with a default behaviour doing nothing.
    • Constructor Detail

      • EndpointAdapter

        public EndpointAdapter()
    • Method Detail

      • onBinaryMessage

        public byte[] onBinaryMessage​(WebSocket ws,
                                      byte[] message)
        Description copied from interface: Endpoint
        A binary message has been received.

        If the return value is not null, then it is sent to the remote endpoint.

        Specified by:
        onBinaryMessage in interface Endpoint
        Parameters:
        ws - the WebSocket on which the event occurred
        message - the received message
        Returns:
        a return message that the WebSocket will send to the remote endpoint
      • onClose

        public void onClose​(WebSocket ws,
                            ReasonForClosure closeReason)
        Description copied from interface: Endpoint
        The associated WebSocket is about to close. This method is called if the remote endpoint started a closing handshake (that is, a close control frame has been received and connection state was OPEN), or if the local application request to close the connection.

        The underlying socket connection may already be closed to you should not try to send any further message in this callback.

        Specified by:
        onClose in interface Endpoint
        Parameters:
        ws - the WebSocket about to be closed
        closeReason - the reason for closing
      • onOpen

        public void onOpen​(WebSocket ws)
        Description copied from interface: Endpoint
        The connection has been established.
        Specified by:
        onOpen in interface Endpoint
        Parameters:
        ws - the WebSocket on which the event occurred
      • onPong

        public void onPong​(byte[] data)
        Description copied from interface: Endpoint
        A pong frame has been received.
        Specified by:
        onPong in interface Endpoint
        Parameters:
        data - the data received in the pong payload
      • onPing

        public void onPing​(byte[] data)
        Description copied from interface: Endpoint
        A ping frame has been received. The pong frame does not need to be sent manually, it will be done automatically by the websocket.
        Specified by:
        onPing in interface Endpoint
        Parameters:
        data - the data received in the ping payload
      • onTextMessage

        public String onTextMessage​(WebSocket ws,
                                    String message)
        Description copied from interface: Endpoint
        A text message has been received.

        If the return value is not null, then it is sent to the remote endpoint.

        Specified by:
        onTextMessage in interface Endpoint
        Parameters:
        ws - the WebSocket on which the event occurred
        message - the received message
        Returns:
        a return message that the WebSocket will send to the remote endpoint