Annotation Interface OnWebSocketMessage


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface OnWebSocketMessage

Annotation for methods to receive BINARY or TEXT WebSocket events.

Acceptable method signatures for text messages:

  1. public void methodName(Session session, *String text)
  2. public void methodName(Session session, *Reader reader)

The * before the parameter type means that the parameter is mandatory.

NOTE

Method that takes a Reader must have WebSocket.autoDemand() set to true.

NOTE

The Reader argument will always use the UTF-8 charset, (as dictated by RFC 6455). If you need to use a different charset, you must use BINARY messages.

Acceptable method signatures for binary messages:

  1. public void methodName(Session session, *ByteBuffer message, *Callback callback)
  2. public void methodName(Session session, *InputStream stream)

The * before the parameter type means that the parameter is mandatory.

NOTE

Method that takes a InputStream must have WebSocket.autoDemand() set to true.

Partial messages are used to receive individual frames (and therefore partial messages) without aggregating the frames into a complete WebSocket message. A boolean parameter is supplied to indicate whether the frame is the last segment of data of the message.

Acceptable method signatures for partial messages:

  1. public void methodName(Session session, *String payload, *boolean last)
  2. public void methodName(Session session, *ByteBuffer payload, *boolean last, *Callback callback)

The * before the parameter type means that the parameter is mandatory.