public class WebSocketAdapter extends Object implements WebSocketListener
WebSocketListener interface.WebSocketListener| Constructor and Description |
|---|
WebSocketAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
handleCallbackError(WebSocket websocket,
Throwable cause)
Called when an
onXxx() method threw a Throwable. |
void |
onBinaryFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a binary frame (opcode = 0x2) was received.
|
void |
onBinaryMessage(WebSocket websocket,
byte[] binary)
Called when a binary message was received.
|
void |
onCloseFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a close frame (opcode = 0x8) was received.
|
void |
onConnected(WebSocket websocket,
Map<String,List<String>> headers)
Called after the opening handshake of the web socket connection succeeded.
|
void |
onConnectError(WebSocket websocket,
WebSocketException exception)
Called when
WebSocket.connectAsynchronously() failed. |
void |
onContinuationFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a continuation frame (opcode = 0x0) was received.
|
void |
onDisconnected(WebSocket websocket,
WebSocketFrame serverCloseFrame,
WebSocketFrame clientCloseFrame,
boolean closedByServer)
Called after the web socket connection was closed.
|
void |
onError(WebSocket websocket,
WebSocketException cause)
Call when an error occurred.
|
void |
onFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a frame was received.
|
void |
onFrameError(WebSocket websocket,
WebSocketException cause,
WebSocketFrame frame)
Called when a frame failed to be read from the web socket.
|
void |
onFrameSent(WebSocket websocket,
WebSocketFrame frame)
Called when a web socket frame was sent to the server
(but not flushed yet).
|
void |
onFrameUnsent(WebSocket websocket,
WebSocketFrame frame)
Called when a web socket frame was not sent to the server
because a close frame has already been sent.
|
void |
onMessageDecompressionError(WebSocket websocket,
WebSocketException cause,
byte[] compressed)
Called when it failed to decompress a message.
|
void |
onMessageError(WebSocket websocket,
WebSocketException cause,
List<WebSocketFrame> frames)
Called when it failed to concatenate payloads of multiple frames
to construct a message.
|
void |
onPingFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a ping frame (opcode = 0x9) was received.
|
void |
onPongFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a pong frame (opcode = 0xA) was received.
|
void |
onSendError(WebSocket websocket,
WebSocketException cause,
WebSocketFrame frame)
Called when an error occurred when a frame was tried to be sent
to the server.
|
void |
onSendingFrame(WebSocket websocket,
WebSocketFrame frame)
Called before a web socket frame is sent.
|
void |
onStateChanged(WebSocket websocket,
WebSocketState newState)
Called after the state of the web socket changed.
|
void |
onTextFrame(WebSocket websocket,
WebSocketFrame frame)
Called when a text frame (opcode = 0x1) was received.
|
void |
onTextMessage(WebSocket websocket,
String text)
Called when a text message was received.
|
void |
onTextMessageError(WebSocket websocket,
WebSocketException cause,
byte[] data)
Called when it failed to convert payload data into a string.
|
void |
onUnexpectedError(WebSocket websocket,
WebSocketException cause)
Called when an uncaught throwable was detected in either the
reading thread (which reads frames from the server) or the
writing thread (which sends frames to the server).
|
public void onStateChanged(WebSocket websocket, WebSocketState newState) throws Exception
WebSocketListeneronStateChanged in interface WebSocketListenerwebsocket - The web socket.newState - The new state of the web socket.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onConnected(WebSocket websocket, Map<String,List<String>> headers) throws Exception
WebSocketListeneronConnected in interface WebSocketListenerwebsocket - The web socket.headers - HTTP headers received from the server. Keys of the map are
HTTP header names such as "Sec-WebSocket-Accept".
Note that the comparator used by the map is String.CASE_INSENSITIVE_ORDER.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onConnectError(WebSocket websocket, WebSocketException exception) throws Exception
WebSocketListenerWebSocket.connectAsynchronously() failed.
Note that this method is called only when connectAsynchronously()
was used and the connect() executed in the
background thread failed. Neither direct synchronous connect()
nor connect(ExecutorService) will trigger this callback method.
onConnectError in interface WebSocketListenerwebsocket - The web socket.exception - The exception thrown by connect()
method.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) throws Exception
WebSocketListeneronDisconnected in interface WebSocketListenerwebsocket - The web socket.serverCloseFrame - The close frame which the server sent to this client.
This may be null.clientCloseFrame - The close frame which this client sent to the server.
This may be null.closedByServer - true if the closing handshake was started by the server.
false if the closing handshake was started by the client.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronXxxFrame method is called.onFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onContinuationFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronContinuationFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronTextFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onBinaryFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronBinaryFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onCloseFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronCloseFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onPingFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronPingFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onPongFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronPongFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onTextMessage(WebSocket websocket, String text) throws Exception
WebSocketListeneronTextMessage in interface WebSocketListenerwebsocket - The web socket.text - The text message.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onBinaryMessage(WebSocket websocket, byte[] binary) throws Exception
WebSocketListeneronBinaryMessage in interface WebSocketListenerwebsocket - The web socket.binary - The binary message.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onSendingFrame(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronSendingFrame in interface WebSocketListenerwebsocket - The web socket.frame - The frame to be sent.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onFrameSent(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListeneronFrameSent in interface WebSocketListenerwebsocket - The web socket.frame - The sent frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onFrameUnsent(WebSocket websocket, WebSocketFrame frame) throws Exception
WebSocketListener
Note that onFrameUnsent is not called when onSendError is called.
onFrameUnsent in interface WebSocketListenerwebsocket - The web socket.frame - The unsent frame.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onError(WebSocket websocket, WebSocketException cause) throws Exception
WebSocketListeneronXxxError method is called.onError in interface WebSocketListenerwebsocket - The web socket.cause - An exception that represents the error.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onFrameError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) throws Exception
WebSocketListeneronFrameError in interface WebSocketListenerwebsocket - The web socket.cause - An exception that represents the error. When the error occurred
because of InterruptedIOException,
exception.getError() returns WebSocketError.INTERRUPTED_IN_READING.
For other IO errors, exception.getError() returns WebSocketError.IO_ERROR_IN_READING. Other error codes denote
protocol errors, which imply that some bugs may exist in either
or both of the client-side and the server-side implementations.frame - The socket frame. If this is not null, it means that
verification of the frame failed.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onMessageError(WebSocket websocket, WebSocketException cause, List<WebSocketFrame> frames) throws Exception
WebSocketListeneronMessageError in interface WebSocketListenerwebsocket - The web socket.cause - An exception that represents the error.frames - The list of frames that form a message. The first element
is either a text frame and a binary frame, and the other
frames are continuation frames.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onMessageDecompressionError(WebSocket websocket, WebSocketException cause, byte[] compressed) throws Exception
WebSocketListeneronMessageDecompressionError in interface WebSocketListenerwebsocket - The web socket.cause - An exception that represents the error.compressed - The compressed message that failed to be decompressed.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onTextMessageError(WebSocket websocket, WebSocketException cause, byte[] data) throws Exception
WebSocketListeneronTextMessageError in interface WebSocketListenerwebsocket - The web socket.cause - An exception that represents the error.data - The payload data that failed to be converted to a string.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onSendError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) throws Exception
WebSocketListeneronSendError in interface WebSocketListenerwebsocket - The web socket.cause - An exception that represents the error.frame - The frame which was tried to be sent. This is null
when the error code of the exception is FLUSH_ERROR.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void onUnexpectedError(WebSocket websocket, WebSocketException cause) throws Exception
WebSocketListeneronUnexpectedError in interface WebSocketListenerwebsocket - The web socket.cause - The cause of the error.Exception - An exception thrown by an implementation of this method.
The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable).public void handleCallbackError(WebSocket websocket, Throwable cause) throws Exception
WebSocketListeneronXxx() method threw a Throwable.handleCallbackError in interface WebSocketListenerwebsocket - The web socket.cause - The Throwable an onXxx method threw.Exception - An exception thrown by an implementation of this method.
The exception is just ignored.Copyright © 2015. All rights reserved.