Annotation Type OnWebSocketMessage


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface OnWebSocketMessage
Annotation for tagging methods to receive Binary or Text Message events.

Acceptable method patterns.
Note: methodName can be any name you want to use.

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: that the Reader in this case will always use UTF-8 encoding/charset (this is dictated by the RFC 6455 spec for Text Messages. If you need to use a non-UTF-8 encoding/charset, you are instructed to use the binary messaging techniques.

Binary Message Versions
  1. public void methodName(ByteBuffer message)
  2. public void methodName(Session session, ByteBuffer message)
  3. public void methodName(byte[] buf, int offset, int length)
  4. public void methodName(Session session, byte[] buf, int offset, int length)
  5. public void methodName(InputStream stream)
  6. public void methodName(Session session, InputStream stream)
Partial Message Variations

These are used to receive partial messages without aggregating them into a complete WebSocket message. Instead the a boolean argument is supplied to indicate whether this is the last segment of data of the message. See WebSocketPartialListener interface for more details on partial messages.

  1. public void methodName(ByteBuffer payload, boolean last)
  2. public void methodName(String payload, boolean last)

Note: Similar to the signatures above these can all be used with an optional first Session parameter.