WebSocketConnectionListener, WebSocketListenerpublic class WebSocketAdapter extends java.lang.Object implements WebSocketListener
WebSocketListener.
Convenient abstract class to base standard WebSocket implementations off of.
| Constructor | Description |
|---|---|
WebSocketAdapter() |
| Modifier and Type | Method | Description |
|---|---|---|
RemoteEndpoint |
getRemote() |
|
Session |
getSession() |
|
boolean |
isConnected() |
|
boolean |
isNotConnected() |
|
void |
onWebSocketBinary(byte[] payload,
int offset,
int len) |
A WebSocket binary frame has been received.
|
void |
onWebSocketClose(int statusCode,
java.lang.String reason) |
A Close Event was received.
|
void |
onWebSocketConnect(Session sess) |
A WebSocket
Session has connected successfully and is ready to be used. |
void |
onWebSocketError(java.lang.Throwable cause) |
A WebSocket exception has occurred.
|
void |
onWebSocketText(java.lang.String message) |
A WebSocket Text frame was received.
|
public RemoteEndpoint getRemote()
public Session getSession()
public boolean isConnected()
public boolean isNotConnected()
public void onWebSocketBinary(byte[] payload,
int offset,
int len)
WebSocketListeneronWebSocketBinary in interface WebSocketListenerpayload - the raw payload array receivedoffset - the offset in the payload array where the data startslen - the length of bytes in the payloadpublic void onWebSocketClose(int statusCode,
java.lang.String reason)
WebSocketConnectionListenerThe underlying Connection will be considered closed at this point.
onWebSocketClose in interface WebSocketConnectionListenerstatusCode - the close status code. (See StatusCode)reason - the optional reason for the close.public void onWebSocketConnect(Session sess)
WebSocketConnectionListenerSession has connected successfully and is ready to be used.
Note: It is a good idea to track this session as a field in your object so that you can write messages back via the RemoteEndpoint
onWebSocketConnect in interface WebSocketConnectionListenersess - the websocket session.public void onWebSocketError(java.lang.Throwable cause)
WebSocketConnectionListenerThis is a way for the internal implementation to notify of exceptions occured during the processing of websocket.
Usually this occurs from bad / malformed incoming packets. (example: bad UTF8 data, frames that are too big, violations of the spec)
This will result in the Session being closed by the implementing side.
onWebSocketError in interface WebSocketConnectionListenercause - the error that occurred.public void onWebSocketText(java.lang.String message)
WebSocketListeneronWebSocketText in interface WebSocketListenermessage - the messageCopyright © 1995–2017 Webtide. All rights reserved.