public abstract class AbstractWebsocketClientEndpoint
extends java.lang.Object
ClientEndpoint
and the appropriate websocket subprotocols because websocket annotations don't work with inheritance. The subclass
must also contain separate methods with the following annotations: OnOpen, OnClose, and OnMessage.| Constructor and Description |
|---|
AbstractWebsocketClientEndpoint(WebsocketClient websocketClient,
java.net.URI endpointURI,
java.lang.String messageThreadName)
Instantiates a new Abstract websocket client endpoint.
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
Connect.
|
void |
disconnect()
Disconnect.
|
javax.websocket.Session |
getUserSession()
Gets user session.
|
protected void |
onClose(javax.websocket.Session userSession,
javax.websocket.CloseReason reason)
On close.
|
protected void |
onMessage(java.lang.String message)
On message.
|
protected void |
onOpen(javax.websocket.Session userSession)
On open.
|
void |
sendMessage(java.lang.String message)
Send a message.
|
public AbstractWebsocketClientEndpoint(WebsocketClient websocketClient, java.net.URI endpointURI, java.lang.String messageThreadName)
websocketClient - the websocket clientendpointURI - the endpoint urimessageThreadName - the message thread namepublic void connect()
throws javax.websocket.DeploymentException,
java.io.IOException
javax.websocket.DeploymentException - the deployment exceptionjava.io.IOException - Signals that an I/O exception has occurred.public void disconnect()
throws java.io.IOException
java.io.IOException - the io exceptionprotected void onOpen(javax.websocket.Session userSession)
userSession - the user sessionprotected void onClose(javax.websocket.Session userSession,
javax.websocket.CloseReason reason)
userSession - the user sessionreason - the reasonprotected void onMessage(java.lang.String message)
message - the messagepublic void sendMessage(java.lang.String message)
message - the messagepublic javax.websocket.Session getUserSession()