Package rocks.xmpp.websocket.net.client
Class WebSocketConnectionConfiguration
- java.lang.Object
-
- rocks.xmpp.core.net.client.ClientConnectionConfiguration
-
- rocks.xmpp.websocket.net.client.WebSocketConnectionConfiguration
-
- All Implemented Interfaces:
ConnectionConfiguration
public final class WebSocketConnectionConfiguration extends ClientConnectionConfiguration
A configuration for a WebSocket connection.It allows you to configure basic connection settings like hostname and port, as well as the path in the WebSocket URI.
Usage
In order to create an instance of this class you have to use the builder pattern as shown below.
WebSocketConnectionConfiguration connectionConfiguration = WebSocketConnectionConfiguration.builder() .hostname("localhost") .port(7443) .path("/ws/") .sslContext(sslContext) .channelEncryption(ChannelEncryption.DIRECT) .connector(new JdkWebSocketConnector()) .build();
The above sample configuration will connect to
wss://localhost:7443/ws/
using SSL with a customSSLContext
.This class is immutable.
- Since:
- 0.7.0
- See Also:
- XMPP Subprotocol for WebSocket
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WebSocketConnectionConfiguration.Builder
A builder to create aWebSocketConnectionConfiguration
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WebSocketConnectionConfiguration.Builder
builder()
Creates a new builder.CompletableFuture<Connection>
createConnection(XmppSession xmppSession, SessionOpen sessionOpen)
A factory method to create the connection.static WebSocketConnectionConfiguration
getDefault()
Gets the default configuration.String
getPath()
Gets the path on the host, e.g.Duration
getPingInterval()
Gets the ping interval.static void
setDefault(WebSocketConnectionConfiguration configuration)
Sets the default configuration.String
toString()
-
Methods inherited from class rocks.xmpp.core.net.client.ClientConnectionConfiguration
getChannelEncryption, getCompressionMethods, getConnectTimeout, getHostname, getHostnameVerifier, getPort, getProxy, getSSLContext
-
-
-
-
Method Detail
-
getDefault
public static WebSocketConnectionConfiguration getDefault()
Gets the default configuration.- Returns:
- The default configuration.
-
setDefault
public static void setDefault(WebSocketConnectionConfiguration configuration)
Sets the default configuration.- Parameters:
configuration
- The default configuration.
-
builder
public static WebSocketConnectionConfiguration.Builder builder()
Creates a new builder.- Returns:
- The builder.
-
getPath
public final String getPath()
Gets the path on the host, e.g. "/ws/".- Returns:
- The path on the host.
-
getPingInterval
public final Duration getPingInterval()
Gets the ping interval.- Returns:
- The ping interval.
- See Also:
WebSocketConnectionConfiguration.Builder.pingInterval(Duration)
-
createConnection
public final CompletableFuture<Connection> createConnection(XmppSession xmppSession, SessionOpen sessionOpen)
Description copied from class:ClientConnectionConfiguration
A factory method to create the connection.- Specified by:
createConnection
in classClientConnectionConfiguration
- Parameters:
xmppSession
- The XMPP session, which is associated with the connection.sessionOpen
- The session open element.- Returns:
- The connection.
-
toString
public final String toString()
- Overrides:
toString
in classClientConnectionConfiguration
-
-