Interface Session.Listener
- All Known Subinterfaces:
Session.Listener.AutoDemanding
- All Known Implementing Classes:
Session.Listener.Abstract, Session.Listener.AbstractAutoDemanding, WebSocketDocs.AutoDemandListenerEndPoint, WebSocketDocs.ConfigureEndpoint, WebSocketDocs.ExplicitDemandListenerEndPoint, WebSocketDocs.ListenerEndPoint, WebSocketDocs.RoundTripListenerEndpoint, WebSocketDocs.StreamingListenerEndpoint, WebSocketDocs.WrongAutoDemandListenerEndPoint
- Enclosing interface:
Session
The passive link of communication with a remote WebSocket endpoint.
Applications provide WebSocket endpoints that implement this interface
to receive WebSocket events from the remote peer, and can use
Session for configuration and to send WebSocket frames or messages
to the other peer.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic interfaceTag interface that signals that the WebSocket endpoint is demanding for WebSocket frames automatically. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidonWebSocketBinary(ByteBuffer payload, Callback callback) A WebSocket BINARY message has been received.default voidonWebSocketClose(int statusCode, String reason) The WebSocketSessionhas been closed.default voidonWebSocketError(Throwable cause) A WebSocket error has occurred during the processing of WebSocket frames.default voidonWebSocketFrame(Frame frame, Callback callback) A WebSocket frame has been received.default voidonWebSocketOpen(Session session) A WebSocketSessionhas opened successfully and is ready to be used.default voidonWebSocketPartialBinary(ByteBuffer payload, boolean last, Callback callback) A WebSocket BINARY (or associated CONTINUATION) frame has been received.default voidonWebSocketPartialText(String payload, boolean last) A WebSocket TEXT (or associated CONTINUATION) frame has been received.default voidonWebSocketPing(ByteBuffer payload) A WebSocket PING frame has been received.default voidonWebSocketPong(ByteBuffer payload) A WebSocket PONG frame has been received.default voidonWebSocketText(String message) A WebSocket TEXT message has been received.
-
Method Details
-
onWebSocketOpen
-
onWebSocketFrame
-
onWebSocketPing
A WebSocket PING frame has been received.
- Parameters:
payload- the PING payload
-
onWebSocketPong
A WebSocket PONG frame has been received.
- Parameters:
payload- the PONG payload
-
onWebSocketPartialBinary
A WebSocket BINARY (or associated CONTINUATION) frame has been received.
The
ByteBufferis read-only, and will be recycled when thecallbackis completed.- Parameters:
payload- the BINARY frame payloadlast- whether this is the last framecallback- the callback to complete when the payload has been processed
-
onWebSocketPartialText
A WebSocket TEXT (or associated CONTINUATION) frame has been received.
- Parameters:
payload- the text message payloadNote that due to framing, there is a above average chance of any UTF8 sequences being split on the border between two frames will result in either the previous frame, or the next frame having an invalid UTF8 sequence, but the combined frames having a valid UTF8 sequence.
The String being provided here will not end in a split UTF8 sequence. Instead this partial sequence will be held over until the next frame is received.
last- whether this is the last frame
-
onWebSocketBinary
A WebSocket BINARY message has been received.
- Parameters:
payload- the raw payload array received
-
onWebSocketText
A WebSocket TEXT message has been received.
- Parameters:
message- the text payload
-
onWebSocketError
A WebSocket error has occurred during the processing of WebSocket frames.
Usually errors occurs from bad or malformed incoming packets, for example text frames that do not contain UTF-8 bytes, frames that are too big, or other violations of the WebSocket specification.
The WebSocket
Sessionwill be closed, but applications may explicitlyclosetheSessionproviding a different status code or reason.- Parameters:
cause- the error that occurred
-
onWebSocketClose
The WebSocket
Sessionhas been closed.- Parameters:
statusCode- the closestatus codereason- the optional reason for the close
-