Package org.asynchttpclient.ws
Interface WebSocketListener
-
public interface WebSocketListener
A genericWebSocketListener
for WebSocket events. Use the appropriate listener for receiving message bytes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
onBinaryFrame(byte[] payload, boolean finalFragment, int rsv)
Invoked when a binary frame is received.void
onClose(WebSocket websocket, int code, String reason)
Invoked when theWebSocket
is closed.void
onError(Throwable t)
Invoked when theWebSocket
crashes.void
onOpen(WebSocket websocket)
Invoked when theWebSocket
is open.default void
onPingFrame(byte[] payload)
Invoked when a ping frame is receiveddefault void
onPongFrame(byte[] payload)
Invoked when a pong frame is receiveddefault void
onTextFrame(String payload, boolean finalFragment, int rsv)
Invoked when a text frame is received.
-
-
-
Method Detail
-
onOpen
void onOpen(WebSocket websocket)
Invoked when theWebSocket
is open.- Parameters:
websocket
- the WebSocket
-
onClose
void onClose(WebSocket websocket, int code, String reason)
Invoked when theWebSocket
is closed.- Parameters:
websocket
- the WebSocketcode
- the status codereason
- the reason message- See Also:
- "http://tools.ietf.org/html/rfc6455#section-5.5.1"
-
onBinaryFrame
default void onBinaryFrame(byte[] payload, boolean finalFragment, int rsv)
Invoked when a binary frame is received.- Parameters:
payload
- a byte arrayfinalFragment
- true if this frame is the final fragmentrsv
- extension bits
-
onTextFrame
default void onTextFrame(String payload, boolean finalFragment, int rsv)
Invoked when a text frame is received.- Parameters:
payload
- a UTF-8String
messagefinalFragment
- true if this frame is the final fragmentrsv
- extension bits
-
onPingFrame
default void onPingFrame(byte[] payload)
Invoked when a ping frame is received- Parameters:
payload
- a byte array
-
onPongFrame
default void onPongFrame(byte[] payload)
Invoked when a pong frame is received- Parameters:
payload
- a byte array
-
-