添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
飘逸的荔枝  ·  WebSockets support in ...·  1 周前    · 
直爽的企鹅  ·  embeding doc of ...·  4 月前    · 
活泼的罐头  ·  GitHub - ...·  5 月前    · 
extends Object implements WebSocketListener
An empty implementation of WebSocketListener interface.
See Also:
WebSocketListener
onDisconnected ( WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer)
Called after the WebSocket connection was closed.
onError ( WebSocket websocket, WebSocketException cause)
Call when an error occurred.
onFrame ( WebSocket websocket, WebSocketFrame frame)
Called when a frame was received.
onFrameError ( WebSocket websocket, WebSocketException cause, WebSocketFrame frame)
Called when a WebSocket frame failed to be read from the WebSocket.
onFrameSent ( WebSocket websocket, WebSocketFrame frame)
Called when a WebSocket frame was sent to the server (but not flushed yet).
onFrameUnsent ( WebSocket websocket, WebSocketFrame frame)
Called when a WebSocket frame was not sent to the server because a close frame has already been sent.
onMessageDecompressionError ( WebSocket websocket, WebSocketException cause, byte[] compressed)
Called when a message failed to be decompressed.
onMessageError ( WebSocket websocket, WebSocketException cause, List < WebSocketFrame > frames)
Called when it failed to concatenate payloads of multiple frames to construct a message.
onPingFrame ( WebSocket websocket, WebSocketFrame frame)
Called when a ping frame (opcode = 0x9) was received.
onPongFrame ( WebSocket websocket, WebSocketFrame frame)
Called when a pong frame (opcode = 0xA) was received.
onSendError ( WebSocket websocket, WebSocketException cause, WebSocketFrame frame)
Called when an error occurred when a frame was tried to be sent to the server.
onSendingFrame ( WebSocket websocket, WebSocketFrame frame)
Called before a WebSocket frame is sent.
onSendingHandshake ( WebSocket websocket, String requestLine, List < String []> headers)
Called before an opening handshake is sent to the server.
onStateChanged ( WebSocket websocket, WebSocketState newState)
Called after the state of the WebSocket changed.
onTextFrame ( WebSocket websocket, WebSocketFrame frame)
Called when a text frame (opcode = 0x1) was received.
onTextMessage ( WebSocket websocket, String text)
Called when a text message was received.
onTextMessageError ( WebSocket websocket, WebSocketException cause, byte[] data)
Called when it failed to convert payload data into a string.
onThreadCreated ( WebSocket websocket, ThreadType threadType, Thread thread)
Called between after a thread is created and before the thread's start() method is called.
onThreadStarted ( WebSocket websocket, ThreadType threadType, Thread thread)
Called at the very beginning of the thread's run() method implementation.
onThreadStopping ( WebSocket websocket, ThreadType threadType, Thread thread)
Called at the very end of the thread's run() method implementation.
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
Description copied from interface: WebSocketListener
Called after the state of the WebSocket changed.
Specified by:
onStateChanged in interface WebSocketListener
Parameters:
websocket - The WebSocket.
newState - The new state of the WebSocket.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onConnected

public void onConnected(WebSocket websocket,
                        Map<String,List<String>> headers)
                 throws Exception
Description copied from interface: WebSocketListener
Called after the opening handshake of the WebSocket connection succeeded.
Specified by:
onConnected in interface WebSocketListener
Parameters:
websocket - The WebSsocket.
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 .
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onConnectError

public void onConnectError(WebSocket websocket,
                           WebSocketException exception)
                    throws Exception
Description copied from interface: WebSocketListener
Called when WebSocket.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.
Specified by:
onConnectError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
exception - The exception thrown by connect() method.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onDisconnected

public void onDisconnected(WebSocket websocket,
                           WebSocketFrame serverCloseFrame,
                           WebSocketFrame clientCloseFrame,
                           boolean closedByServer)
                    throws Exception
Description copied from interface: WebSocketListener
Called after the WebSocket connection was closed.
Specified by:
onDisconnected in interface WebSocketListener
Parameters:
websocket - The WebSocket.
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.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a frame was received. This method is called before an on Xxx Frame method is called.
Specified by:
onFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The frame.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onContinuationFrame

public void onContinuationFrame(WebSocket websocket,
                                WebSocketFrame frame)
                         throws Exception
Description copied from interface: WebSocketListener
Called when a continuation frame (opcode = 0x0) was received.
Specified by:
onContinuationFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The continuation frame.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a text frame (opcode = 0x1) was received.
Specified by:
onTextFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The text frame.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a binary frame (opcode = 0x2) was received.
Specified by:
onBinaryFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The binary frame.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a close frame (opcode = 0x8) was received.
Specified by:
onCloseFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The close frame .
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a ping frame (opcode = 0x9) was received.
Specified by:
onPingFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The ping frame .
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a pong frame (opcode = 0xA) was received.
Specified by:
onPongFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The pong frame .
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
throws Exception
Description copied from interface: WebSocketListener
Called when a text message was received.
Specified by:
onTextMessage in interface WebSocketListener
Parameters:
websocket - The WebSocket.
text - The text message.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
throws Exception
Description copied from interface: WebSocketListener
Called when a binary message was received.
Specified by:
onBinaryMessage in interface WebSocketListener
Parameters:
websocket - The WebSocket.
binary - The binary message.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called before a WebSocket frame is sent.
Specified by:
onSendingFrame in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The WebSocket frame to be sent.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a WebSocket frame was sent to the server (but not flushed yet).
Specified by:
onFrameSent in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The sent frame.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketFrame frame) throws Exception
Description copied from interface: WebSocketListener
Called when a WebSocket frame was not sent to the server because a close frame has already been sent. Note that onFrameUnsent is not called when onSendError is called.
Specified by:
onFrameUnsent in interface WebSocketListener
Parameters:
websocket - The WebSocket.
frame - The unsent frame.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
WebSocketException cause) throws Exception
Description copied from interface: WebSocketListener
Call when an error occurred. This method is called before an on Xxx Error method is called.
Specified by:
onError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
cause - An exception that represents the error.
Throws:
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
Description copied from interface: WebSocketListener
Called when a WebSocket frame failed to be read from the WebSocket. Some WebSocket server implementations close a WebSocket connection without sending a close frame to a client in some cases. Strictly speaking, this behavior is a violation against the specification ( RFC 6455 ). However, this library has allowed the behavior by default since the version 1.29. Even if the end of the input stream of a WebSocket connection were reached without a close frame being received, it would trigger neither onError() method nor onFrameError() method. If you want to make this library report an error in the case, pass false to WebSocket.setMissingCloseFrameAllowed(boolean) method.
Specified by:
onFrameError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
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 WebSocket frame. If this is not null , it means that verification of the frame failed.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onMessageError

public void onMessageError(WebSocket websocket,
                           WebSocketException cause,
                           List<WebSocketFrame> frames)
                    throws Exception
Description copied from interface: WebSocketListener
Called when it failed to concatenate payloads of multiple frames to construct a message. The reason of the failure is probably out-of-memory.
Specified by:
onMessageError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
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.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onMessageDecompressionError

public void onMessageDecompressionError(WebSocket websocket,
                                        WebSocketException cause,
                                        byte[] compressed)
                                 throws Exception
Description copied from interface: WebSocketListener
Called when a message failed to be decompressed.
Specified by:
onMessageDecompressionError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
cause - An exception that represents the error.
compressed - The compressed message that failed to be decompressed.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onTextMessageError

public void onTextMessageError(WebSocket websocket,
                               WebSocketException cause,
                               byte[] data)
                        throws Exception
Description copied from interface: WebSocketListener
Called when it failed to convert payload data into a string. The reason of the failure is probably out-of-memory.
Specified by:
onTextMessageError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
cause - An exception that represents the error.
data - The payload data that failed to be converted to a string.
Throws:
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
Description copied from interface: WebSocketListener
Called when an error occurred when a frame was tried to be sent to the server.
Specified by:
onSendError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
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 .
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onUnexpectedError

public void onUnexpectedError(WebSocket websocket,
                              WebSocketException cause)
                       throws Exception
Description copied from interface: WebSocketListener
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).
Specified by:
onUnexpectedError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
cause - The cause of the error.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

handleCallbackError

public void handleCallbackError(WebSocket websocket,
                                Throwable cause)
                         throws Exception
Description copied from interface: WebSocketListener
Called when an on Xxx () method threw a Throwable .
Specified by:
handleCallbackError in interface WebSocketListener
Parameters:
websocket - The WebSocket.
cause - The Throwable an on Xxx method threw.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is just ignored.

onSendingHandshake

public void onSendingHandshake(WebSocket websocket,
                               String requestLine,
                               List<String[]> headers)
                        throws Exception
Description copied from interface: WebSocketListener
Called before an opening handshake is sent to the server.
Specified by:
onSendingHandshake in interface WebSocketListener
Parameters:
websocket - The WebSocket.
requestLine - The request line. For example, "GET /chat HTTP/1.1" .
headers - The HTTP headers.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
throws Exception
Description copied from interface: WebSocketListener
Called between after a thread is created and before the thread's start() method is called.
Specified by:
onThreadCreated in interface WebSocketListener
Parameters:
websocket - The WebSocket.
threadType - The thread type.
thread - The newly created thread instance.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .
throws Exception
Description copied from interface: WebSocketListener
Called at the very beginning of the thread's run() method implementation.
Specified by:
onThreadStarted in interface WebSocketListener
Parameters:
websocket - The WebSocket.
threadType - The thread type.
thread - The thread instance.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .

onThreadStopping

public void onThreadStopping(WebSocket websocket,
                             ThreadType threadType,
                             Thread thread)
                      throws Exception
Description copied from interface: WebSocketListener
Called at the very end of the thread's run() method implementation.
Specified by:
onThreadStopping in interface WebSocketListener
Parameters:
websocket - The WebSocket.
threadType - The thread type.
thread - The thread instance.
Throws:
Exception - An exception thrown by an implementation of this method. The exception is passed to WebSocketListener.handleCallbackError(WebSocket, Throwable) .