java.lang.Object
org.miaixz.bus.http.plugin.httpv.CoverHttp<CoverCall.Client>
org.miaixz.bus.http.plugin.httpv.CoverCall.Client
- All Implemented Interfaces:
Cancelable
- Enclosing class:
CoverCall
A client for creating and configuring WebSocket connections.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested classes/interfaces inherited from class org.miaixz.bus.http.plugin.httpv.CoverHttp
CoverHttp.Async, CoverHttp.Sync -
Field Summary
Fields inherited from class org.miaixz.bus.http.plugin.httpv.CoverHttp
httpv, nextOnIO, nothrow, skipPreproc, skipSerialPreproc -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionheatbeat(int pingSeconds, int pongSeconds) Sets the heartbeat interval, overriding the default heartbeat mode.listen()Starts the WebSocket connection and returns aCoverCallto interact with it.intintsetOnClosed(CoverCall.Register<CoverCall.Close> onClosed) Sets the closed listener (also called on cancellation or exception).setOnClosing(CoverCall.Register<CoverCall.Close> onClosing) Sets the closing listener.setOnException(CoverCall.Register<Throwable> onException) Sets the connection exception listener.setOnMessage(CoverCall.Register<CoverCall.Message> onMessage) Sets the message listener.setOnOpen(CoverCall.Register<CoverResult> onOpen) Sets the open connection listener.Methods inherited from class org.miaixz.bus.http.plugin.httpv.CoverHttp
addBodyPara, addBodyPara, addFilePara, addFilePara, addFilePara, addFilePara, addHeader, addHeader, addPathPara, addPathPara, addUrlPara, addUrlPara, assertNotConflict, bind, bodyType, cancel, charset, charset, getBodyType, getBound, getHeaders, getTag, getUrl, isTagged, nextOnIO, nothrow, prepareCall, prepareRequest, registeTagTask, removeTagTask, setBodyPara, setOnProcess, setRange, setRange, skipPreproc, skipSerialPreproc, stepBytes, stepRate, tag, timeoutAwait, timeoutResult, toState
-
Constructor Details
-
Client
Constructs a new WebSocket client.- Parameters:
client- The HTTP client instance.url- The WebSocket URL.
-
-
Method Details
-
heatbeat
Sets the heartbeat interval, overriding the default heartbeat mode.Key differences: 1. Any message sent by the client acts as a heartbeat. 2. Any message sent by the server acts as a heartbeat. 3. A timeout is only triggered if the server does not reply within 3 * pongSeconds. 4. The specific content of the heartbeat can be specified (defaults to empty).
- Parameters:
pingSeconds- The client's heartbeat interval in seconds (0 means no heartbeat).pongSeconds- The server's heartbeat interval in seconds (0 means no heartbeat).- Returns:
- this client instance for chaining.
-
listen
Starts the WebSocket connection and returns aCoverCallto interact with it.- Returns:
- The CoverCall representing the connection.
-
setOnOpen
Sets the open connection listener.- Parameters:
onOpen- The listener.- Returns:
- this client instance for chaining.
-
setOnException
Sets the connection exception listener.- Parameters:
onException- The listener.- Returns:
- this client instance for chaining.
-
setOnMessage
Sets the message listener.- Parameters:
onMessage- The listener.- Returns:
- this client instance for chaining.
-
setOnClosing
Sets the closing listener.- Parameters:
onClosing- The listener.- Returns:
- this client instance for chaining.
-
setOnClosed
Sets the closed listener (also called on cancellation or exception).- Parameters:
onClosed- The listener.- Returns:
- this client instance for chaining.
-
pingSeconds
public int pingSeconds()- Returns:
- The configured client-to-server ping interval in seconds.
-
pongSeconds
public int pongSeconds()- Returns:
- The configured expected server-to-client pong interval in seconds.
-