|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Retention(value=RUNTIME) @Target(value=METHOD) public @interface WebSocketMessage
This method level annotation can be used to make a Java method receive incoming web socket messages. Each websocket
endpoint may only have one message handling method for each of the native websocket message formats: text, binary and pong. Methods
using this annotation are allowed to have
parameters of types described below, otherwise the container will generate an error at deployment time.
The allowed parameters are:
String to receive the whole messageReader to receive the whole message as a blocking streamDecoder.Text or
Decoder.TextStream).ByteBuffer to receive the whole messageByteBuffer and boolean pair to receive the message in partsInputStream to receive the whole message as a blocking streamDecoder.Binary or
Decoder.BinaryStream).PongMessage for handling pong messagesWebSocketPathParam annotation for server endpoints.Session parameter
@WebSocketMessage
public void processGreeting(String message, Session session) {
System.out.println("Greeting received:" + message);
}
For example:
@WebSocketMessage
public void processUpload(byte[] b, boolean last, Session session) {
// process partial data here, which check on last to see if these is more on the way
}
Developers should not continue to reference message objects of type Reader, ByteBuffer
or InputStream after the annotated method has completed, since they
may be recycled by the implementation.
| Optional Element Summary | |
|---|---|
long |
maxMessageSize
Specifies the maximum size of message in bytes that the method this annotates will be able to process, or -1 to indicate that there is no maximum. |
public abstract long maxMessageSize
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||