public class StringWebSocketClient extends WebSocketClient implements CanHandleMessages<java.lang.String>, CanHandleErrors, CanHandleConnects, CanHandleDisconnects
Constructor and Description |
---|
StringWebSocketClient() |
Modifier and Type | Method and Description |
---|---|
void |
connect(java.net.URI endpoint)
Connects web socket client.
|
java.util.List<java.lang.Runnable> |
getConnectionHandlers()
Returns a list of all registered web socket connection handlers.
|
java.util.List<java.lang.Runnable> |
getDisconnectionHandlers()
Returns a list of all registered web socket disconnection handlers.
|
java.util.List<java.util.function.Consumer<java.lang.Throwable>> |
getErrorHandlers()
Returns a list of all registered web socket error handlers.
|
java.util.List<java.util.function.Consumer<java.lang.String>> |
getMessageHandlers()
Returns a list of all registered web socket messages handlers.
|
void |
onClose()
This event if fired when the client is
disconnected from a web socket.
|
void |
onError(java.lang.Throwable cause)
This event if fired when there is an unexpected
error in web socket connection.
|
void |
onMessage(java.lang.String message)
This event if fired when there is a
new message from the web socket.
|
void |
onOpen(javax.websocket.Session session)
This event if fired when the client is successfully
connected to a web socket.
|
void |
removeAllHandlers()
Remove all the registered handlers.
|
getEndpoint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addMessageHandler, removeMessageHandlers
addErrorHandler, removeErrorHandlers
addConnectionHandler, removeConnectionHandlers
addDisconnectionHandler, removeDisconnectionHandlers
public void connect(java.net.URI endpoint)
WebSocketClient
connect
in class WebSocketClient
endpoint
- The full address of an endpoint to connect to.
Usually starts with 'ws://'.public void onOpen(javax.websocket.Session session)
session
- the actual web socket session instancepublic void onClose()
public void onError(java.lang.Throwable cause)
cause
- the actual error reasonpublic void onMessage(java.lang.String message)
message
- the actual message content.public java.util.List<java.util.function.Consumer<java.lang.String>> getMessageHandlers()
CanHandleMessages
getMessageHandlers
in interface CanHandleMessages<java.lang.String>
public java.util.List<java.util.function.Consumer<java.lang.Throwable>> getErrorHandlers()
CanHandleErrors
getErrorHandlers
in interface CanHandleErrors
public java.util.List<java.lang.Runnable> getConnectionHandlers()
CanHandleConnects
getConnectionHandlers
in interface CanHandleConnects
public java.util.List<java.lang.Runnable> getDisconnectionHandlers()
CanHandleDisconnects
getDisconnectionHandlers
in interface CanHandleDisconnects
public void removeAllHandlers()