Package org.eclipse.jetty.websocket.api
Class WebSocketAdapter
java.lang.Object
org.eclipse.jetty.websocket.api.WebSocketAdapter
- All Implemented Interfaces:
WebSocketConnectionListener,WebSocketListener
Default implementation of the
WebSocketListener.
Convenient abstract class to base standard WebSocket implementations off of.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidonWebSocketBinary(byte[] payload, int offset, int len) A WebSocket binary frame has been received.voidonWebSocketClose(int statusCode, String reason) A Close Event was received.voidonWebSocketConnect(Session sess) A WebSocketSessionhas connected successfully and is ready to be used.voidonWebSocketError(Throwable cause) A WebSocket exception has occurred.voidonWebSocketText(String message) A WebSocket Text frame was received.
-
Constructor Details
-
WebSocketAdapter
public WebSocketAdapter()
-
-
Method Details
-
getRemote
-
getSession
-
isConnected
public boolean isConnected() -
isNotConnected
public boolean isNotConnected() -
onWebSocketBinary
public void onWebSocketBinary(byte[] payload, int offset, int len) Description copied from interface:WebSocketListenerA WebSocket binary frame has been received.- Specified by:
onWebSocketBinaryin interfaceWebSocketListener- Parameters:
payload- the raw payload array receivedoffset- the offset in the payload array where the data startslen- the length of bytes in the payload
-
onWebSocketClose
Description copied from interface:WebSocketConnectionListenerA Close Event was received.The underlying Connection will be considered closed at this point.
- Specified by:
onWebSocketClosein interfaceWebSocketConnectionListener- Parameters:
statusCode- the close status code. (SeeStatusCode)reason- the optional reason for the close.
-
onWebSocketConnect
Description copied from interface:WebSocketConnectionListenerA WebSocketSessionhas 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- Specified by:
onWebSocketConnectin interfaceWebSocketConnectionListener- Parameters:
sess- the websocket session.
-
onWebSocketError
Description copied from interface:WebSocketConnectionListenerA WebSocket exception has occurred.This 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
Sessionbeing closed by the implementing side.- Specified by:
onWebSocketErrorin interfaceWebSocketConnectionListener- Parameters:
cause- the error that occurred.
-
onWebSocketText
Description copied from interface:WebSocketListenerA WebSocket Text frame was received.- Specified by:
onWebSocketTextin interfaceWebSocketListener- Parameters:
message- the message
-