public class StringWebSocketClient extends okhttp3.WebSocketListener 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.net.URI |
getEndpoint() |
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.
|
boolean |
isListening() |
void |
onClosing(okhttp3.WebSocket webSocket,
int code,
java.lang.String reason) |
void |
onFailure(okhttp3.WebSocket webSocket,
java.lang.Throwable t,
okhttp3.Response response) |
void |
onMessage(okhttp3.WebSocket webSocket,
java.lang.String text) |
void |
onOpen(okhttp3.WebSocket webSocket,
okhttp3.Response response) |
void |
removeAllHandlers()
Remove all the registered handlers.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addMessageHandler, removeMessageHandlers
addErrorHandler, removeErrorHandlers
addConnectionHandler, removeConnectionHandlers
addDisconnectionHandler, removeDisconnectionHandlers
@Nullable public java.net.URI getEndpoint()
public boolean isListening()
public void connect(java.net.URI endpoint)
endpoint
- The full address of an endpoint to connect to.
Usually starts with 'ws://'.public void onOpen(okhttp3.WebSocket webSocket, okhttp3.Response response)
onOpen
in class okhttp3.WebSocketListener
public void onClosing(okhttp3.WebSocket webSocket, int code, java.lang.String reason)
onClosing
in class okhttp3.WebSocketListener
public void onFailure(okhttp3.WebSocket webSocket, java.lang.Throwable t, okhttp3.Response response)
onFailure
in class okhttp3.WebSocketListener
public void onMessage(okhttp3.WebSocket webSocket, java.lang.String text)
onMessage
in class okhttp3.WebSocketListener
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()