javax.websocket
Annotation Type WebSocketMessage


@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. It must have parameters of the following types otherwise the container will generate an error at deployment time
String / byte[] / or decodable (as determined by the Decoders configured for the endpoint) parameter
Optional Session parameter
Zero to n String parameters annotated with the @WebSocketPathParam annotation.

The parameters may be listed in any order.

The method may have a non-void return type, in which case the web socket runtime must interpret this as a web socket message to return to the peer. The allowed data types for this return type, other than void, are String, ByteBuffer, byte[], any java primitive or class equivalent, and array or Collection of any of the previous types, plus anything for which there is a decoder.

For example:

 @WebSocketMessage;
public void processGreeting(String message, Session session) {
  System.out.println("Greeting received:" + message);
}

Since:
Draft 002
Author:
dannycoward

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.
 

maxMessageSize

public abstract 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. The default is -1.

Returns:
the maximum size in bytes.
Default:
-1L



Copyright © 2012 Oracle and/or its affiliates. All rights reserved.