public.javadoc.org.spincast.plugins.httpclient.websocket.builders.WebsocketRequestBuilderDefault.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
WebsocketRequestBuilderDefault (org.spincast:spincast-framework 1.0.0 API)
org.spincast.plugins.httpclient.websocket.builders
Class WebsocketRequestBuilderDefault
- java.lang.Object
-
- org.spincast.plugins.httpclient.builders.HttpRequestBuilderBase<WebsocketRequestBuilder>
-
- org.spincast.plugins.httpclient.websocket.builders.WebsocketRequestBuilderDefault
-
- All Implemented Interfaces:
- HttpRequestBuilder<WebsocketRequestBuilder>, WebsocketRequestBuilder
public class WebsocketRequestBuilderDefault
extends HttpRequestBuilderBase<WebsocketRequestBuilder>
implements WebsocketRequestBuilder
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
WebsocketRequestBuilderDefault(String url,
CookieFactory cookieFactory,
HttpResponseFactory spincastHttpResponseFactory,
SpincastHttpClientWithWebsocketUtils spincastHttpClientWithWebsocketUtils,
SpincastHttpClientWithWebsocketConfig spincastHttpClientWithWebsocketConfig)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
protected void
addCustomCookies(Map<String,List<String>> headers)
protected void
addCustomHeaders(Map<String,List<String>> headers)
protected void
addHttpAuthHeaders(Map<String,List<String>> headers)
protected void
addSslContext(io.undertow.websockets.client.WebSocketClient.ConnectionBuilder connectionBuilder)
protected void
addWebsocketRequestHeaders()
WebsocketClientWriter
connect(WebsocketClientHandler websocketClientHandler)
Sends the request and establish the WebSocket connection.
protected io.undertow.server.DefaultByteBufferPool
createByteBufferPool()
protected io.undertow.websockets.client.WebSocketClient.ConnectionBuilder
createConnectionBuilder(org.xnio.XnioWorker worker,
io.undertow.server.DefaultByteBufferPool bufferPool,
String url)
protected org.spincast.shaded.org.apache.http.client.methods.HttpRequestBase
createMethodSpecificHttpRequest(String url)
Creates the HttpRequestBase depending on the HTTP method.
protected List<io.undertow.websockets.WebSocketExtension>
createSupportedExtensions()
protected List<String>
createSupportedSubProtocols()
protected io.undertow.websockets.core.WebSocketChannel
createWebSocketChannel()
protected io.undertow.websockets.core.WebSocketChannel
createWebSocketChannel(org.xnio.XnioWorker worker,
io.undertow.server.DefaultByteBufferPool bufferPool,
String url,
int redirectionNbr)
protected URI
createWebsocketUri(String url)
protected org.xnio.XnioWorker
createXnioWorker()
protected int
getPingsIntervalSeconds()
protected SpincastHttpClientWithWebsocketConfig
getSpincastHttpClientWithWebsocketConfig()
protected SpincastHttpClientWithWebsocketUtils
getSpincastHttpClientWithWebsocketUtils()
protected SSLContext
getSslContext()
protected ExecutorService
getThreadExecutorForClientEvents()
The ExecutorService to use to
send events to the client.
protected int
getThreadExecutorForClientEventsThreadNumber()
The maximum number of concurrent threads used when
sending events to the application.
protected ThreadFactory
getThreadExecutorForClientEventsThreadThreadFactory()
The ThreadFactory to use for the Executor that
sends events to the client.
protected int
getThreadExecutorForClientEventsTimeoutAmount()
The timeout amount before cancelling a task when
sending events to the application.
protected TimeUnit
getThreadExecutorForClientEventsTimeoutTimeUnit()
The timeout asdasd before cancelling a task when
sending events to the application.
protected WebsocketClientHandler
getWebsocketClientReader()
protected io.undertow.websockets.core.WebSocketCallback<Void>
getWebsocketWriteCallback(WebsocketClientHandler reader)
protected org.xnio.Xnio
getXnio()
WebsocketRequestBuilder
ping(int seconds)
You can use this to configure the pings that are automatically sent
to the Websocket endpoint every X seconds.
HttpResponse
send()
Sends the request and gets the HTTP response.
protected void
sendClientEventInNewThread(Runnable runnable)
Sends an event to the client in a separated thread.
protected void
sendConnectionClosedAppEvent(WebsocketClientHandler reader)
protected void
sendOnBytesMessageClientEvent(byte[] message)
Sends a "Bytes message" event to the app.
protected void
sendOnConnectionClosedMessageClientEvent(int code,
String reason)
Sends a "Connection closed message" event to the app.
protected void
sendOnStringMessageClientEvent(String message)
Sends a "String message" event to the app.
protected void
startSendingPings(SpincastWebsocketClientWriter writer)
-
Methods inherited from class org.spincast.plugins.httpclient.builders.HttpRequestBuilderBase
addHeaderValue, addHeaderValues, addHTMLAcceptHeader, addJsonAcceptHeader, addPlainTextAcceptHeader, addXMLAcceptHeader, convertToApacheCookie, createHttpClient, createHttpClientBuilder, disableRedirectHandling, disableSslCertificateErrors, getCookieEncoding, getCookieFactory, getCookieStore, getHeaders, getHttpAuthPassword, getHttpAuthUsername, getHttpClient, getHttpClientBuilder, getHttpRequestExecutor, getRequestConfig, getSpincastHttpClientConfig, getSpincastHttpClientUtils, getSpincastHttpResponseFactory, getUrl, isDisableRedirectHandling, isDisableSslCertificateErrors, sendGetRawResponse, setCookie, setCookie, setCookie, setCookies, setCookieStore, setHeaders, setHeaderValues, setHttpAuthCredentials, setHttpClientBuilder, setRequestConfig
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
-
Constructor Detail
-
WebsocketRequestBuilderDefault
public WebsocketRequestBuilderDefault(String url,
CookieFactory cookieFactory,
HttpResponseFactory spincastHttpResponseFactory,
SpincastHttpClientWithWebsocketUtils spincastHttpClientWithWebsocketUtils,
SpincastHttpClientWithWebsocketConfig spincastHttpClientWithWebsocketConfig)
Constructor
-
Method Detail
-
getSpincastHttpClientWithWebsocketConfig
protected SpincastHttpClientWithWebsocketConfig getSpincastHttpClientWithWebsocketConfig()
-
getSpincastHttpClientWithWebsocketUtils
protected SpincastHttpClientWithWebsocketUtils getSpincastHttpClientWithWebsocketUtils()
-
createMethodSpecificHttpRequest
protected org.spincast.shaded.org.apache.http.client.methods.HttpRequestBase createMethodSpecificHttpRequest(String url)
Description copied from class: HttpRequestBuilderBase
Creates the HttpRequestBase depending on the HTTP method.
- Specified by:
createMethodSpecificHttpRequest
in class HttpRequestBuilderBase<WebsocketRequestBuilder>
-
getPingsIntervalSeconds
protected int getPingsIntervalSeconds()
-
getWebsocketClientReader
protected WebsocketClientHandler getWebsocketClientReader()
-
ping
public WebsocketRequestBuilder ping(int seconds)
Description copied from interface: WebsocketRequestBuilder
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.
- Specified by:
ping
in interface WebsocketRequestBuilder
- Parameters:
seconds
- the interval in seconds or <= 0 to disable the pings.
-
send
public HttpResponse send()
Description copied from interface: HttpRequestBuilder
Sends the request and gets the HTTP response.
- Specified by:
send
in interface HttpRequestBuilder<WebsocketRequestBuilder>
- Specified by:
send
in interface WebsocketRequestBuilder
- Overrides:
send
in class HttpRequestBuilderBase<WebsocketRequestBuilder>
- Returns:
- A object containg the parsed information of the response.
-
addWebsocketRequestHeaders
protected void addWebsocketRequestHeaders()
-
connect
public WebsocketClientWriter connect(WebsocketClientHandler websocketClientHandler)
Description copied from interface: WebsocketRequestBuilder
Sends the request and establish the WebSocket connection.
- Specified by:
connect
in interface WebsocketRequestBuilder
- Parameters:
websocketClientHandler
- The handler that is responsible to
handle the various WebSocket events.
- Returns:
- a writer to send WebSocket messages to the connected endpoint.
-
getWebsocketWriteCallback
protected io.undertow.websockets.core.WebSocketCallback<Void> getWebsocketWriteCallback(WebsocketClientHandler reader)
-
startSendingPings
protected void startSendingPings(SpincastWebsocketClientWriter writer)
-
getXnio
protected org.xnio.Xnio getXnio()
-
createXnioWorker
protected org.xnio.XnioWorker createXnioWorker()
-
getSslContext
protected SSLContext getSslContext()
-
createByteBufferPool
protected io.undertow.server.DefaultByteBufferPool createByteBufferPool()
-
createWebSocketChannel
protected io.undertow.websockets.core.WebSocketChannel createWebSocketChannel()
-
createWebSocketChannel
protected io.undertow.websockets.core.WebSocketChannel createWebSocketChannel(org.xnio.XnioWorker worker,
io.undertow.server.DefaultByteBufferPool bufferPool,
String url,
int redirectionNbr)
-
createConnectionBuilder
protected io.undertow.websockets.client.WebSocketClient.ConnectionBuilder createConnectionBuilder(org.xnio.XnioWorker worker,
io.undertow.server.DefaultByteBufferPool bufferPool,
String url)
-
addSslContext
protected void addSslContext(io.undertow.websockets.client.WebSocketClient.ConnectionBuilder connectionBuilder)
-
createSupportedExtensions
protected List<io.undertow.websockets.WebSocketExtension> createSupportedExtensions()
-
sendConnectionClosedAppEvent
protected void sendConnectionClosedAppEvent(WebsocketClientHandler reader)
-
sendOnStringMessageClientEvent
protected void sendOnStringMessageClientEvent(String message)
Sends a "String message" event to the app.
-
sendOnBytesMessageClientEvent
protected void sendOnBytesMessageClientEvent(byte[] message)
Sends a "Bytes message" event to the app.
-
sendOnConnectionClosedMessageClientEvent
protected void sendOnConnectionClosedMessageClientEvent(int code,
String reason)
Sends a "Connection closed message" event to the app.
-
sendClientEventInNewThread
protected void sendClientEventInNewThread(Runnable runnable)
Sends an event to the client in a separated thread.
-
getThreadExecutorForClientEventsTimeoutAmount
protected int getThreadExecutorForClientEventsTimeoutAmount()
The timeout amount before cancelling a task when
sending events to the application.
-
getThreadExecutorForClientEventsTimeoutTimeUnit
protected TimeUnit getThreadExecutorForClientEventsTimeoutTimeUnit()
The timeout asdasd before cancelling a task when
sending events to the application.
-
getThreadExecutorForClientEvents
protected ExecutorService getThreadExecutorForClientEvents()
The ExecutorService to use to
send events to the client.
-
getThreadExecutorForClientEventsThreadNumber
protected int getThreadExecutorForClientEventsThreadNumber()
The maximum number of concurrent threads used when
sending events to the application.
-
getThreadExecutorForClientEventsThreadThreadFactory
protected ThreadFactory getThreadExecutorForClientEventsThreadThreadFactory()
The ThreadFactory to use for the Executor that
sends events to the client.
- Returns:
- the ThreadFactory to use or
null
to use the default one.
Copyright © 2019. All rights reserved.