Annotation Interface OnWebSocketMessage


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

Annotation for methods to receive BINARY or TEXT WebSocket events.

Acceptable method patterns:

Text Message Versions
  1. public void methodName(String text)
  2. public void methodName(Session session, String text)
  3. public void methodName(Reader reader)
  4. public void methodName(Session session, Reader reader)

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.

Binary Message Versions
  1. public void methodName(ByteBuffer message, Callback callback)
  2. public void methodName(Session session, ByteBuffer message, Callback callback)
  3. public void methodName(InputStream stream)
  4. public void methodName(Session session, InputStream stream)

NOTE

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

Partial Message Variations

These 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.

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