Interface WebsocketRequestBuilder
- All Superinterfaces:
HttpRequestBuilder<WebsocketRequestBuilder>
- All Known Implementing Classes:
WebsocketRequestBuilderDefault
Builder to create a WebSocket requesté
-
Method Summary
Modifier and TypeMethodDescriptionconnect
(WebsocketClientHandler handler) Sends the request and establish the WebSocket connection.ping
(int seconds) You can use this to configure the pings that are automatically sent to the Websocket endpoint every X seconds.send()
Sends the request and gets theHTTP
response.Methods inherited from interface org.spincast.plugins.httpclient.HttpRequestBuilder
addHeaderValue, addHeaderValues, addHTMLAcceptHeader, addJsonAcceptHeader, addPlainTextAcceptHeader, addXMLAcceptHeader, disableRedirectHandling, disableSslCertificateErrors, setCookie, setCookie, setCookie, setCookies, setHeaders, setHeaderValues, setHttpAuthCredentials, setHttpClientBuilder, setRequestConfig
-
Method Details
-
ping
You can use this to configure the pings that are automatically sent to the Websocket endpoint every X seconds.WebsocketClientHandler#onConnectionClosed()
will be called if the connection is closed.Use a value
<= 0
to disable the pings.The automatic pings and their default interval are also configurable using:
SpincastHttpClientWithWebsocketConfig#isWebsocketAutomaticPingEnabled()
and
SpincastHttpClientWithWebsocketConfig#getWebsocketAutomaticPingIntervalSeconds()
Pings are enabled by default.
- Parameters:
seconds
- the interval in seconds or <= 0 to disable the pings.
-
connect
Sends the request and establish the WebSocket connection.- Parameters:
handler
- The handler that is responsible to handle the various WebSocket events.- Returns:
- a writer to send WebSocket messages to the connected endpoint.
-
send
HttpResponse send()Sends the request and gets theHTTP
response. Does not make the actual upgrade to a WebSocket connection! Use theconnect(...)
method if you want the actual WebSocket connection to be made.This version is useful to debug the intermediate
HTTP
upgrade response made from the server before the actual WebSocket connection is established.- Specified by:
send
in interfaceHttpRequestBuilder<WebsocketRequestBuilder>
-