Class WebsocketFactoryBuilder
WebSocketFactory. Results in a UniversalisWsBuilder-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the factory and returns an universalis websocket builder with the factory.setConnectionTimeout(int timeout) Set the timeout value in milliseconds for socket connection.setDualStackFallbackDelay(int delay) Set the dual stack fallback delay in milliseconds that will be applied when establishing a socket connection.setDualStackMode(com.neovisionaries.ws.client.DualStackMode mode) Set the dual stack mode that will be applied when establishing a socket connection.setServerName(String serverName) Set a server name for SNI (Server Name Indication).setServerNames(String[] serverNames) Set server names for SNI (Server Name Indication).setSocketTimeout(int timeout) Set the timeout value in milliseconds for socket read and write operations.setSSLContext(SSLContext context) Set an SSL context to get a socket factory.setSSLSocketFactory(SSLSocketFactory factory) Set an SSL socket factory.setVerifyHostname(boolean verifyHostname) Set the flag which indicates whether the hostname in the server's certificate should be verified or not.
-
Constructor Details
-
WebsocketFactoryBuilder
public WebsocketFactoryBuilder()
-
-
Method Details
-
setSSLSocketFactory
Set an SSL socket factory. SeeWebSocketFactory.createSocket(URI)for details.- Parameters:
factory- An SSL socket factory.- Returns:
thisinstance.
-
setSSLContext
Set an SSL context to get a socket factory. SeeWebSocketFactory.createSocket(URI)for details.- Parameters:
context- An SSL context.- Returns:
thisinstance.
-
setConnectionTimeout
Set the timeout value in milliseconds for socket connection. A timeout of zero is interpreted as an infinite timeout.- Parameters:
timeout- The connection timeout value in milliseconds.- Returns:
thisobject.- Throws:
IllegalArgumentException- The given timeout value is negative.- Since:
- 1.10
-
setSocketTimeout
Set the timeout value in milliseconds for socket read and write operations. A timeout of zero is interpreted as an infinite timeout.This can be changed later with
getSocket().setSoTimeout(int).- Parameters:
timeout- The socket timeout value in milliseconds.- Returns:
thisobject.- Throws:
IllegalArgumentException- The given timeout value is negative.- Since:
- 2.14
- See Also:
-
setDualStackMode
Set the dual stack mode that will be applied when establishing a socket connection.- Parameters:
mode- The dual stack mode to be applied.- Returns:
thisobject.
-
setDualStackFallbackDelay
Set the dual stack fallback delay in milliseconds that will be applied when establishing a socket connection.- Parameters:
delay- The dual stack fallback delay in milliseconds.- Returns:
thisobject.
-
setVerifyHostname
Set the flag which indicates whether the hostname in the server's certificate should be verified or not. The default value istrue.Manual hostname verification has been enabled since the version 2.1. Because the verification is executed manually after
Socket.connect(SocketAddress, int)succeeds, the hostname verification is always executed even if you has passed anSSLContextwhich naively accepts any server certificate (e.g.NaiveSSLContext). However, this behavior is not desirable in some cases and you may want to disable the hostname verification. This setter method exists for the purpose and you can disable hostname verification by passingfalseto this method.- Parameters:
verifyHostname-trueto enable hostname verification.falseto disable hostname verification.- Returns:
thisobject.- Since:
- 2.3
-
setServerNames
Set server names for SNI (Server Name Indication).If
setServerNames(List<SNIServerName>)method ofSSLParametersclass is available in the underlying system, the method is called to set up server names for SNI (Server Name Indication).- Parameters:
serverNames- List of host names.- Returns:
thisobject.- Since:
- 2.4
-
setServerName
Set a server name for SNI (Server Name Indication).This method internally creates a String array of size 1 which contains the given
serverNameand callssetServerNames(String[]).- Parameters:
serverName- A host name.- Returns:
thisobject.- Since:
- 2.4
-
build
Build the factory and returns an universalis websocket builder with the factory.- Returns:
- universalis websocket builder
-