java.lang.Object
org.miaixz.bus.http.socket.WebSocketListener
- Direct Known Subclasses:
CoverCall.Listener
A listener for events related to a WebSocket connection.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked when both peers have indicated that no more messages will be transmitted and the connection has been successfully released.voidInvoked when the remote peer has indicated that no more incoming messages will be transmitted.voidInvoked when a web socket has been closed due to an error reading from or writing to the network.voidInvoked when a text (type0x1) message has been received.voidInvoked when a binary (type0x2) message has been received.voidInvoked when a web socket has been accepted by the remote peer and may begin transmitting messages.
-
Constructor Details
-
WebSocketListener
public WebSocketListener()
-
-
Method Details
-
onOpen
Invoked when a web socket has been accepted by the remote peer and may begin transmitting messages.- Parameters:
webSocket- The WebSocket that has been opened.response- The HTTP response from the upgrade request.
-
onMessage
Invoked when a text (type0x1) message has been received.- Parameters:
webSocket- The WebSocket that received the message.text- The text content of the message.
-
onMessage
Invoked when a binary (type0x2) message has been received.- Parameters:
webSocket- The WebSocket that received the message.bytes- The binary content of the message.
-
onClosing
Invoked when the remote peer has indicated that no more incoming messages will be transmitted.- Parameters:
webSocket- The WebSocket that is closing.code- The status code from the remote peer.reason- The reason for the closure, or an empty string.
-
onClosed
Invoked when both peers have indicated that no more messages will be transmitted and the connection has been successfully released. No further calls to this listener will be made.- Parameters:
webSocket- The WebSocket that has been closed.code- The status code from the remote peer.reason- The reason for the closure, or an empty string.
-
onFailure
Invoked when a web socket has been closed due to an error reading from or writing to the network. Both outgoing and incoming messages may have been lost. No further calls to this listener will be made.- Parameters:
webSocket- The WebSocket that failed.throwable- The exception that caused the failure.response- The HTTP response from the upgrade request, or null if no response was received.
-