public interface WebsocketController<R extends RequestContext<?>,W extends WebsocketContext<?>>
| Modifier and Type | Method and Description |
|---|---|
void |
onEndpointClosed(String endpointId)
The endpoint is now closed.
|
void |
onEndpointReady(WebsocketEndpointManager endpointManager)
This method is called when a new endpoint is created and its manager
is ready.
|
void |
onPeerClosed(W context)
A peer closed the WebSocket connection.
|
void |
onPeerConnected(W context)
A peer is connected on the WebSocket endpoint.
|
void |
onPeerMessage(W context,
byte[] message)
A peer sent a bytes[] message.
|
void |
onPeerMessage(W context,
String message)
A Peer sent a String message.
|
WebsocketConnectionConfig |
onPeerPreConnect(R context)
Called before the HTTP request is converted to a
WebSocket connection.
|
WebsocketConnectionConfig onPeerPreConnect(R context)
Allows you to decide which endpoint and which peer id to use for the WebSocket connection. You still have access to the request parameters, the cookies, so you can make a decision based on those.
null is returned, the WebSocket
connection won't be established.void onEndpointReady(WebsocketEndpointManager endpointManager)
IMPORTANT: To make sure you receive this manager before the connection with the very first peer is established, to prevent any concurrency issues, this method is actually called synchronously in the same thread handling the connection with that first peer. This means this method should not block! If you use this method to start a loop and send messages, for example, then the WebSocket connection with the first peer will fail...
To use this method as a starting point to send events to the peers, start a new Thread in it and return immediately.
void onPeerConnected(W context)
void onPeerMessage(W context, byte[] message)
void onPeerClosed(W context)
void onEndpointClosed(String endpointId)
Copyright © 2019. All rights reserved.