Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Annotated WebSocket Server Endpoint example
//annotated server endpoint with all its configuration elements
@ServerEnpdoint(
value = "/chat/",
configurator = ChatEndpointConfigurator.class,
decoders = JSONToChatObjectDecoder.class,
encoders = ChatObjectToJSONEncoder.class,
subprotocols = {"chat"}
)
public class ChatServer {
//server endpoint configuration in action
@OnOpen
public void onOpenCallback(Session session,
EndpointConfig epConfig) //injected by the WebSocket runtime
{
ServerEndpointConfig serverConfig = (ServerEndpointConfig) epConfig;
Map<String, Object> globalPropertiesMap = serverConfig.getUserProperties();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment