Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/1efbcd63ba93c77de94b9af46a2806ad to your computer and use it in GitHub Desktop.
Save abhirockzz/1efbcd63ba93c77de94b9af46a2806ad to your computer and use it in GitHub Desktop.
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