Class WebSocket
- All Implemented Interfaces:
AutoCloseable
Connect to WebSocket servers and exchange client-side frames and messages.
Client-side only:
Chilkat.WebSocket implements the client side of the WebSocket
protocol. It initiates an opening handshake with an existing WebSocket
server. It does not listen for incoming connections, accept clients, or
implement a WebSocket server.
Chilkat.WebSocket operates over an established
Chilkat.Rest connection. It creates and validates the HTTP
upgrade handshake, sends and receives text or binary frames, supports
fragmented messages, handles Ping, Pong, and Close control frames, polls for
incoming data, and exposes frame-level diagnostics.
Client opening handshake
Upgrade a connected Rest session to WebSocket and validate
the server's response before exchanging frames.
Text and binary messages
Send UTF-8 text or exact binary bytes as single-frame or fragmented WebSocket messages.
Frame-by-frame receiving
Read frames, inspect opcodes and the FIN state, and accumulate fragments until a complete message is available.
Ping and Pong
Use automatic or manual control-frame handling for keep-alive and responsiveness checks.
Clean close handshake
Exchange Close frames, inspect the peer's status code and reason, and terminate the underlying connection cleanly.
Separate read/write paths
Share a connection between two WebSocket objects when one thread needs to read while another writes.
Typical connection sequence:
Connect a Rest object to the server, call
UseConnection, call AddClientHeaders, send the
opening HTTP GET request through Rest, and then
call ValidateServerHandshake. Only after validation succeeds
should the application call frame send/receive methods.
Frames versus messages:
A WebSocket message may consist of one frame or several fragments. When
receiving a fragmented message, call ReadFrame until
FinalFrame is true, then retrieve the accumulated data with
GetFrameData, GetFrameDataSb, or
GetFrameDataBd.
For an extended overview, see WebSocket Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the standard client opening-handshake headers to theRestobject supplied toUseConnection:voidImmediately closes the underlying network connection without completing the WebSocket closing handshake.booleanControls whether Chilkat automatically answers an incoming Close control frame.Returns the UTF-8 reason text contained in the received Close control frame.booleantrueafter a Close control frame has been received on the current WebSocket connection.intReturns the status code contained in the received Close control frame.booleantrueif the frame most recently delivered byReadFramehad its WebSocketFINbit set; otherwisefalse.Returns the bytes accumulated by successful calls toReadFrameas a string, then clears the internal receive buffer.voidgetFrameDataBd(BinData binData)Appends the bytes accumulated by successful calls toReadFrametobinData, then clears the internal receive buffer.intReturns the number of payload bytes currently accumulated in the internal receive buffer.voidAppends the text represented by the bytes accumulated by successful calls toReadFrametosb, then clears the internal receive buffer.Returns the symbolic opcode of the frame most recently delivered byReadFrame.intReturns the numeric opcode of the frame most recently delivered byReadFrame.intSpecifies the interval, in milliseconds, betweenAbortCheckevent callbacks during supported blocking operations.intSpecifies the maximum number of milliseconds an active send or receive operation may remain stalled while waiting for additional network progress.booleantruewhen the underlying WebSocket network connection is currently open; otherwisefalse.booleantruewhen a Ping frame has been received but no corresponding Pong has yet been sent.booleanControls automatic handling of incoming Ping control frames.booleanControls whether incoming Pong control frames are hidden from the application.booleantrueif the most recent call toReadFrameinternally consumed a Pong frame whilePongAutoConsumewastrue.Returns the installed listener, ornull.intWhenReadFramereturnsfalse, this property categorizes the reason:Contains a comma-separated list of rarely needed compatibility or platform options.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.booleanChecks whether bytes are currently waiting to be read from the underlying WebSocket connection.voidReads the next WebSocket frame from the connected server.voidSends a WebSocket Close control frame and begins or completes the closing handshake.voidSends one WebSocket text data frame containingstringToSend.voidsendFrameBd(BinData bdToSend, boolean finalFrame)Sends one WebSocket binary data frame containing the current bytes inbdToSend.voidsendFrameSb(StringBuilder sbToSend, boolean finalFrame)Sends one WebSocket text data frame containing the current contents ofsbToSend.voidSends a WebSocket Ping control frame.voidsendPong()Sends a WebSocket Pong control frame.voidsetCloseAutoRespond(boolean value)Sets theCloseAutoRespondproperty; seegetCloseAutoRespond().voidsetHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().voidsetIdleTimeoutMs(int value)Sets theIdleTimeoutMsproperty; seegetIdleTimeoutMs().voidsetPingAutoRespond(boolean value)Sets thePingAutoRespondproperty; seegetPingAutoRespond().voidsetPongAutoConsume(boolean value)Sets thePongAutoConsumeproperty; seegetPongAutoConsume().voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidshareConnection(WebSocket ws)Causes the callingWebSocketobject to share the already-established WebSocket connection owned byws.voiduseConnection(Rest connection)Associates thisWebSocketobject with an existing, connectedRestobject and prepares it for a client-side WebSocket session.voidValidates the server's response to the WebSocket opening handshake sent through the associatedRestobject.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
WebSocket
public WebSocket()Creates a newWebSocketobject.
-
-
Method Details
-
getCloseAutoRespond
public boolean getCloseAutoRespond()Controls whether Chilkat automatically answers an incoming Close control frame.- When
true, an incoming Close is answered automatically if the client did not already initiate the close. After a Close has been both received and sent, Chilkat closes the underlying connection. - When
false, the application can detect the received Close throughCloseReceivedorFrameOpcodeand callSendCloseitself.
The default is
true.Closing handshake: A peer that receives a Close and has not already sent one should respond with a Close. Automatic response is usually the safest choice unless the application must control the exact status code or timing.
- Returns:
- the value of the
CloseAutoRespondproperty
- When
-
setCloseAutoRespond
public void setCloseAutoRespond(boolean value)Sets theCloseAutoRespondproperty; seegetCloseAutoRespond().- Parameters:
value- the new value
-
getCloseReason
Returns the UTF-8 reason text contained in the received Close control frame.The value is empty when the peer supplied no reason or when no Close frame has been received. A reason is diagnostic text and should not be treated as a stable machine-readable error identifier; use
CloseStatusCodefor protocol-level handling.- Returns:
- the value of the
CloseReasonproperty (read-only)
-
getCloseReceived
public boolean getCloseReceived()trueafter a Close control frame has been received on the current WebSocket connection.When
CloseAutoRespondisfalse, use this property to determine whether the application needs to callSendCloseto complete the closing handshake. The received status code and reason, if present, are available throughCloseStatusCodeandCloseReason.- Returns:
- the value of the
CloseReceivedproperty (read-only)
-
getCloseStatusCode
public int getCloseStatusCode()Returns the status code contained in the received Close control frame.Returns
0when no Close frame has been received or when the received Close frame did not include a status code.Meaning of zero:
0is an API sentinel; it is not a WebSocket close status transmitted by the peer.- Returns:
- the value of the
CloseStatusCodeproperty (read-only)
-
getFinalFrame
public boolean getFinalFrame()trueif the frame most recently delivered byReadFramehad its WebSocketFINbit set; otherwisefalse.For a fragmented data message, continue reading while this property is
false. The fragment withtruecompletes the message. Unfragmented messages havetrueon their only frame.Control frames: Close, Ping, and Pong are control frames and are not fragmented by the WebSocket protocol; their
FINbit is always set.- Returns:
- the value of the
FinalFrameproperty (read-only)
-
getFrameDataLen
public int getFrameDataLen()Returns the number of payload bytes currently accumulated in the internal receive buffer.The value can represent data from one frame or from multiple calls to
ReadFrame, which is useful when receiving a fragmented message. The accumulated bytes remain available until retrieved byGetFrameData,GetFrameDataSb, orGetFrameDataBd.Message length: This is the length accumulated so far, not necessarily the final length of the complete WebSocket message. Check
FinalFrameto determine whether the last received fragment completed the message.- Returns:
- the value of the
FrameDataLenproperty (read-only)
-
getFrameOpcode
Returns the symbolic opcode of the frame most recently delivered byReadFrame.Value Meaning
ContinuationA later fragment of a Text or Binary messageTextUTF-8 text dataBinaryBinary dataCloseClosing handshakePingPing control framePongPong control frameBefore any frame has been received, the value is the empty string. Ping or Pong frames handled internally by the auto-response/auto-consume options may not be returned as the current frame.
- Returns:
- the value of the
FrameOpcodeproperty (read-only)
-
getFrameOpcodeInt
public int getFrameOpcodeInt()Returns the numeric opcode of the frame most recently delivered byReadFrame.Value Frame type
0Continuation1Text2Binary8Close9Ping10PongUse
FrameOpcodewhen a readable symbolic value is preferred.- Returns:
- the value of the
FrameOpcodeIntproperty (read-only)
-
getHeartbeatMs
public int getHeartbeatMs()Specifies the interval, in milliseconds, betweenAbortCheckevent callbacks during supported blocking operations.The default is
0, which disables periodicAbortCheckcallbacks. Set a positive value when the application needs an opportunity to cancel a long-running send or receive operation.Not a WebSocket heartbeat: Despite the property name, this setting does not transmit Ping frames and does not monitor peer liveness. Use
SendPingand Ping/Pong handling for protocol-level heartbeat behavior.- Returns:
- the value of the
HeartbeatMsproperty
-
setHeartbeatMs
public void setHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().- Parameters:
value- the new value
-
getIdleTimeoutMs
public int getIdleTimeoutMs()Specifies the maximum number of milliseconds an active send or receive operation may remain stalled while waiting for additional network progress.The default is
30000milliseconds (30 seconds). This is an inactivity timeout, not a total limit on the duration of the operation. An operation may continue longer than this value as long as data continues to be transferred.Not a keep-alive interval: This property does not automatically send WebSocket Ping frames. Use
SendPingwhen the application needs protocol-level keep-alive or responsiveness checks.- Returns:
- the value of the
IdleTimeoutMsproperty
-
setIdleTimeoutMs
public void setIdleTimeoutMs(int value)Sets theIdleTimeoutMsproperty; seegetIdleTimeoutMs().- Parameters:
value- the new value
-
getIsConnected
public boolean getIsConnected()truewhen the underlying WebSocket network connection is currently open; otherwisefalse.Connection state is not a health check: A network interruption may not be detected until the next read or write operation. Use normal I/O results—and optionally Ping/Pong—to determine whether a seemingly connected peer is still responsive.
- Returns:
- the value of the
IsConnectedproperty (read-only)
-
getNeedSendPong
public boolean getNeedSendPong()truewhen a Ping frame has been received but no corresponding Pong has yet been sent.This property is primarily useful when
PingAutoRespondisfalse. CallSendPongas soon as practical; it automatically sends the received Ping payload in the Pong response.- Returns:
- the value of the
NeedSendPongproperty (read-only)
-
getPingAutoRespond
public boolean getPingAutoRespond()Controls automatic handling of incoming Ping control frames.- When
true, Chilkat sends the required Pong automatically andReadFrameconsumes the Ping internally, continuing until another frame is available. - When
false, the Ping can be returned to the application. CheckNeedSendPongand callSendPongas soon as practical.
The default is
true.Payload echo: A Pong sent in response to a Ping must carry the same application data.
SendPongautomatically uses the stored payload of the unanswered Ping.- Returns:
- the value of the
PingAutoRespondproperty
- When
-
setPingAutoRespond
public void setPingAutoRespond(boolean value)Sets thePingAutoRespondproperty; seegetPingAutoRespond().- Parameters:
value- the new value
-
getPongAutoConsume
public boolean getPongAutoConsume()Controls whether incoming Pong control frames are hidden from the application.- When
true,ReadFrameconsumes Pong frames internally and continues reading until a non-Pong frame is available. - When
false, an incoming Pong can be returned normally withFrameOpcodeequal toPong.
The default is
true. CheckPongConsumedafterReadFrameto learn whether one or more Pong frames were consumed during that call.- Returns:
- the value of the
PongAutoConsumeproperty
- When
-
setPongAutoConsume
public void setPongAutoConsume(boolean value)Sets thePongAutoConsumeproperty; seegetPongAutoConsume().- Parameters:
value- the new value
-
getPongConsumed
public boolean getPongConsumed()trueif the most recent call toReadFrameinternally consumed a Pong frame whilePongAutoConsumewastrue.The property is reset to
falseat the beginning of eachReadFramecall and set totrueif a Pong is consumed during that call.Why unsolicited Pong is possible: Either endpoint may send a Pong without a preceding Ping, and a response to an earlier Ping may arrive between application data frames. Automatic consumption allows ordinary read loops to ignore these control frames while still detecting that they occurred.
- Returns:
- the value of the
PongConsumedproperty (read-only)
-
getReadFrameFailReason
public int getReadFrameFailReason()WhenReadFramereturnsfalse, this property categorizes the reason:Value Meaning
0No failure is recorded1Read inactivity timeout2Aborted by an application callback3Fatal socket error or lost connection4Invalid WebSocket frame bytes were received99Unexpected catch-all failureUse this value for programmatic branching and inspect
LastErrorTextfor detailed diagnostics.- Returns:
- the value of the
ReadFrameFailReasonproperty (read-only)
-
getUncommonOptions
Contains a comma-separated list of rarely needed compatibility or platform options. The default is the empty string and should normally remain unchanged.Keyword Effect
ProtectFromVpnOn Android, attempts to route the connection outside an installed or active VPN. Introduced in v9.5.0.80.Platform-specific behavior: This option applies only on Android. Leave the property empty on other platforms and unless bypassing the device VPN is an explicit application requirement.
- Returns:
- the value of the
UncommonOptionsproperty (read-only)
-
addClientHeaders
public void addClientHeaders()Adds the standard client opening-handshake headers to theRestobject supplied toUseConnection:Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: ... Sec-WebSocket-Version: 13
Sec-WebSocket-Keycontains a newly generated client nonce used by the server to produceSec-WebSocket-Accept.Additional handshake headers: If the server requires headers such as
Origin,Authorization, cookies, orSec-WebSocket-Protocol, add them through the associatedRestobject before sending the HTTP upgrade request.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
closeConnection
public void closeConnection()Immediately closes the underlying network connection without completing the WebSocket closing handshake.Use this method when the connection must be abandoned because of a fatal error, timeout, application shutdown, or an unresponsive peer.
Preferred shutdown: For a normal shutdown, call
SendClose, receive the peer's Close frame withReadFrame, and allow the closing handshake to complete. An abrupt transport close does not provide the peer with a WebSocket status code or reason.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getFrameData
Returns the bytes accumulated by successful calls toReadFrameas a string, then clears the internal receive buffer.This method is intended for WebSocket text-message data. For arbitrary binary payloads, use
GetFrameDataBdto avoid interpreting binary bytes as text.Fragmented messages: To retrieve an entire fragmented message, continue calling
ReadFrameuntilFinalFrameistrue, and then callGetFrameDataonce. Calling this method earlier returns and clears only the data accumulated so far.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getFrameDataBd
Appends the bytes accumulated by successful calls toReadFrametobinData, then clears the internal receive buffer.Use this method for binary messages or whenever the exact received bytes must be preserved. Existing data in the destination
BinDatais retained because the received bytes are appended.Receive-buffer ownership: Calling any one of
GetFrameData,GetFrameDataSb, orGetFrameDataBdconsumes the same internal buffer. Retrieve the data using only the form needed by the application.- Parameters:
binData- thebinDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getFrameDataSb
Appends the text represented by the bytes accumulated by successful calls toReadFrametosb, then clears the internal receive buffer.Existing text in the destination
StringBuilderis retained. This method is most appropriate for text-message data; useGetFrameDataBdfor arbitrary binary payloads.Fragmented messages: The receive buffer can accumulate multiple frames. Read until
FinalFrameistruebefore calling this method when the application wants the complete message.- Parameters:
sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
pollDataAvailable
public boolean pollDataAvailable()Checks whether bytes are currently waiting to be read from the underlying WebSocket connection.Returns
truewhen incoming data is available andfalsewhen no data is presently waiting.Polling is only a snapshot: A
trueresult does not mean that an entire WebSocket frame or message has arrived. CallReadFrameto parse the protocol frame. Afalseresult does not indicate that the peer will not send data later.- Returns:
- the result; this method never throws
ChilkatException
-
readFrame
public void readFrame()Reads the next WebSocket frame from the connected server. On success, the method updatesFrameOpcode,FrameOpcodeInt,FinalFrame, andFrameDataLen.Frame payload bytes are added to an internal receive buffer. The buffer may therefore contain data accumulated by multiple calls to
ReadFrame. Retrieve and clear it withGetFrameData,GetFrameDataSb, orGetFrameDataBd.Reading a complete message
Call
ReadFrameuntilFinalFrameistrue, then retrieve the accumulated message data. A fragmented message begins with a Text or Binary frame and continues with one or more Continuation frames.Control-frame automation: Depending on
PingAutoRespondandPongAutoConsume, incoming Ping and Pong frames may be handled internally, causing this method to continue reading until another frame is available. If the method returnsfalse, inspectReadFrameFailReasonandLastErrorText.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sendClose
Sends a WebSocket Close control frame and begins or completes the closing handshake.- If
includeStatusisfalse, the Close frame contains no status code andstatusCodeandreasonare ignored. - If
includeStatusistrue, the frame containsstatusCodefollowed by the UTF-8 bytes ofreason.
The complete Close payload cannot exceed 125 bytes, leaving at most 123 bytes for the UTF-8 reason after the two-byte status code. Chilkat truncates an overlong reason. The API accepts status-code integers from 0 through 16383.
Protocol-valid status codes: The API's numeric range is broader than the set valid for transmission under RFC 6455. Use a defined protocol code such as
1000for normal closure, or an appropriate application code in the3000–4999range. Codes1005,1006, and1015are reserved reporting values and must not be sent in a Close frame.Clean close: After initiating a close, read the peer's Close response. If this method answers a Close already received from the server, Chilkat also closes the underlying connection after sending the response.
- Parameters:
includeStatus- theincludeStatusargumentstatusCode- thestatusCodeargumentreason- thereasonargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- If
-
sendFrame
Sends one WebSocket text data frame containingstringToSend. WebSocket text data is UTF-8 on the wire.- Set
finalFrametotruewhen this frame completes the message. - Set
finalFrametofalsewhen additional frames will follow as part of the same fragmented message.
For a normal unfragmented text message, call this method once with
finalFrameset totrue. For a fragmented message, call it repeatedly and settrueonly for the final fragment.Frames and messages: A WebSocket message may contain one frame or multiple fragments. Do not begin a second data message until the current fragmented message has been completed. Control frames such as Ping, Pong, and Close may occur between message fragments.
- Parameters:
stringToSend- thestringToSendargument (notnull)finalFrame- thefinalFrameargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Set
-
sendFrameBd
Sends one WebSocket binary data frame containing the current bytes inbdToSend.- Set
finalFrametotruewhen this frame completes the binary message. - Set
finalFrametofalsewhen additional binary-message fragments will follow.
For an ordinary single-frame binary message, set
finalFrametotrue.Exact bytes: No text encoding is involved. The bytes stored in
bdToSendbecome the frame payload, while Chilkat applies the client-side WebSocket framing and masking required by the protocol.- Parameters:
bdToSend- thebdToSendargument (notnull)finalFrame- thefinalFrameargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Set
-
sendFrameSb
Sends one WebSocket text data frame containing the current contents ofsbToSend.- Set
finalFrametotruewhen this frame completes the message. - Set
finalFrametofalsewhen more fragments will follow.
For an ordinary single-frame text message, set
finalFrametotrue. WebSocket text data is UTF-8 on the wire.Message fragmentation: Repeated calls with
finalFrameset tofalsecreate fragments of the same text message. Complete the message with a final call that passestrue.- Parameters:
sbToSend- thesbToSendargument (notnull)finalFrame- thefinalFrameargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Set
-
sendPing
Sends a WebSocket Ping control frame. IfpingDatais non-empty, its UTF-8 bytes are included as the Ping payload.WebSocket control-frame payloads are limited to 125 bytes. If the UTF-8 representation exceeds this limit, Chilkat truncates it to 125 bytes.
Ping/Pong behavior: A peer that receives a Ping is expected to send a Pong containing the same application data as soon as practical. Ping is useful for protocol-level liveness checks, but receiving a Pong does not by itself prove that the application running above the connection is healthy.
- Parameters:
pingData- thepingDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sendPong
public void sendPong()Sends a WebSocket Pong control frame.When a Ping has been received and has not yet been answered, this method automatically uses the previously received Ping payload as the Pong payload, as required for a Ping response.
Manual response mode: This method is normally used when
PingAutoRespondisfalseandNeedSendPongistrue. When automatic Ping handling is enabled, Chilkat sends the Pong internally.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
useConnection
Associates thisWebSocketobject with an existing, connectedRestobject and prepares it for a client-side WebSocket session.The opening WebSocket handshake is an HTTP
GETupgrade request. UsingRestfor the underlying connection allows the application to configure TLS, proxies, authentication, custom request headers, IPv6, socket options, bandwidth limits, and other connection features before the upgrade is performed.Client-side API: Chilkat.WebSocket initiates connections to WebSocket servers. It does not listen for incoming connections or implement a WebSocket server endpoint.
Typical opening sequence
- Connect the
Restobject to the server. - Call
UseConnection. - Call
AddClientHeaders. - Send the HTTP
GETrequest with theRestobject. - Call
ValidateServerHandshake.
- Parameters:
connection- theconnectionargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Connect the
-
validateServerHandshake
public void validateServerHandshake()Validates the server's response to the WebSocket opening handshake sent through the associatedRestobject.Validation checks that the server accepted the HTTP upgrade and returned the expected WebSocket handshake response, including the value derived from the client's
Sec-WebSocket-Key. If this method returnstrue, the connection has entered the WebSocket protocol and data or control frames may be exchanged.Call order: Call this method only after the
Restobject has sent the openingGETrequest and received the server's response. A successful HTTP request alone does not establish a WebSocket session; the response must also pass this validation.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-