public interface WebSocketListener
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.String |
getFlashPolicy(WebSocket conn) |
java.net.InetSocketAddress |
getLocalSocketAddress(WebSocket conn) |
java.net.InetSocketAddress |
getRemoteSocketAddress(WebSocket conn) |
void |
onWebsocketClose(WebSocket ws,
int code,
java.lang.String reason,
boolean remote)
Called after WebSocket#close is explicity called, or when the
other end of the WebSocket connection is closed.
|
void |
onWebsocketCloseInitiated(WebSocket ws,
int code,
java.lang.String reason)
send when this peer sends a close handshake
|
void |
onWebsocketClosing(WebSocket ws,
int code,
java.lang.String reason,
boolean remote)
Called as soon as no further frames are accepted
|
void |
onWebsocketError(WebSocket conn,
java.lang.Exception ex)
Called if an exception worth noting occurred.
|
void |
onWebsocketHandshakeReceivedAsClient(WebSocket conn,
ClientHandshake request,
ServerHandshake response)
Called on the client side when the socket connection is first established, and the WebSocketImpl
handshake response has been received.
|
ServerHandshakeBuilder |
onWebsocketHandshakeReceivedAsServer(WebSocket conn,
Draft draft,
ClientHandshake request)
Called on the server side when the socket connection is first established, and the WebSocket
handshake has been received.
|
void |
onWebsocketHandshakeSentAsClient(WebSocket conn,
ClientHandshake request)
Called on the client side when the socket connection is first established, and the WebSocketImpl
handshake has just been sent.
|
void |
onWebsocketMessage(WebSocket conn,
java.nio.ByteBuffer blob)
Called when an entire binary frame has been received.
|
void |
onWebsocketMessage(WebSocket conn,
java.lang.String message)
Called when an entire text frame has been received.
|
void |
onWebsocketMessageFragment(WebSocket conn,
Framedata frame)
Called when a frame fragment has been recieved
|
void |
onWebsocketOpen(WebSocket conn,
Handshakedata d)
Called after onHandshakeReceived returns true.
|
void |
onWebsocketPing(WebSocket conn,
Framedata f)
Called a ping frame has been received.
|
void |
onWebsocketPong(WebSocket conn,
Framedata f)
Called when a pong frame is received.
|
void |
onWriteDemand(WebSocket conn)
This method is used to inform the selector thread that there is data queued to be written to the socket.
|
ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket conn, Draft draft, ClientHandshake request) throws InvalidDataException
conn - The WebSocket related to this eventdraft - The protocol draft the client uses to connectrequest - The opening http message send by the client. Can be used to access additional fields like cookies.InvalidDataException - Throwing this exception will cause this handshake to be rejectedvoid onWebsocketHandshakeReceivedAsClient(WebSocket conn, ClientHandshake request, ServerHandshake response) throws InvalidDataException
conn - The WebSocket related to this eventrequest - The handshake initially send out to the server by this websocket.response - The handshake the server sent in response to the request.InvalidDataException - Allows the client to reject the connection with the server in respect of its handshake response.void onWebsocketHandshakeSentAsClient(WebSocket conn, ClientHandshake request) throws InvalidDataException
conn - The WebSocket related to this eventrequest - The handshake sent to the server by this websocketInvalidDataException - Allows the client to stop the connection from progressingvoid onWebsocketMessage(WebSocket conn, java.lang.String message)
conn - The WebSocket instance this event is occurring on.message - The UTF-8 decoded message that was received.void onWebsocketMessage(WebSocket conn, java.nio.ByteBuffer blob)
conn - The WebSocket instance this event is occurring on.blob - The binary message that was received.void onWebsocketMessageFragment(WebSocket conn, Framedata frame)
conn - The WebSocket instance this event is occurring on.frame - The fragmented framevoid onWebsocketOpen(WebSocket conn, Handshakedata d)
conn - The WebSocket instance this event is occuring on.d - The handshake of the websocket instancevoid onWebsocketClose(WebSocket ws, int code, java.lang.String reason, boolean remote)
ws - The WebSocket instance this event is occuring on.code - The codes can be looked up here: CloseFramereason - Additional information stringremote - Returns whether or not the closing of the connection was initiated by the remote host.void onWebsocketClosing(WebSocket ws, int code, java.lang.String reason, boolean remote)
ws - The WebSocket instance this event is occuring on.code - The codes can be looked up here: CloseFramereason - Additional information stringremote - Returns whether or not the closing of the connection was initiated by the remote host.void onWebsocketCloseInitiated(WebSocket ws, int code, java.lang.String reason)
ws - The WebSocket instance this event is occuring on.code - The codes can be looked up here: CloseFramereason - Additional information stringvoid onWebsocketError(WebSocket conn, java.lang.Exception ex)
conn - The WebSocket instance this event is occuring on.ex - The exception that occurred. void onWebsocketPing(WebSocket conn, Framedata f)
conn - The WebSocket instance this event is occuring on.f - The ping frame. Control frames may contain payload.void onWebsocketPong(WebSocket conn, Framedata f)
conn - The WebSocket instance this event is occuring on.f - The pong frame. Control frames may contain payload.java.lang.String getFlashPolicy(WebSocket conn) throws InvalidDataException
conn - The WebSocket instance this event is occuring on.InvalidDataException - thrown when some data that is required to generate the flash-policy like the websocket local port could not be obtained.WebSocketAdapter.getFlashPolicy(WebSocket)void onWriteDemand(WebSocket conn)
conn - The WebSocket instance this event is occuring on.java.net.InetSocketAddress getLocalSocketAddress(WebSocket conn)
conn - The WebSocket instance this event is occuring on.WebSocket.getLocalSocketAddress()java.net.InetSocketAddress getRemoteSocketAddress(WebSocket conn)
conn - The WebSocket instance this event is occuring on.null if it is unconnected.WebSocket.getRemoteSocketAddress()