public class ClientManager extends BaseContainer implements WebSocketContainer
Modifier and Type | Class and Description |
---|---|
static class |
ClientManager.ReconnectHandler
Reconnect handler.
|
Modifier and Type | Field and Description |
---|---|
static String |
HANDSHAKE_TIMEOUT
Property usable in
getProperties() . |
static String |
RECONNECT_HANDLER
Property usable in
getProperties() . |
Constructor and Description |
---|
ClientManager()
Create new
ClientManager instance. |
Modifier and Type | Method and Description |
---|---|
Future<Session> |
asyncConnectToServer(Class<?> annotatedEndpointClass,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Class, java.net.URI) . |
Future<Session> |
asyncConnectToServer(Class<? extends Endpoint> endpointClass,
ClientEndpointConfig cec,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Class, javax.websocket.ClientEndpointConfig, java.net.URI) . |
Future<Session> |
asyncConnectToServer(Endpoint endpointInstance,
ClientEndpointConfig cec,
URI path)
|
Future<Session> |
asyncConnectToServer(Object obj,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Object, java.net.URI) . |
Session |
connectToServer(Class<? extends Endpoint> endpointClass,
ClientEndpointConfig cec,
URI path)
Connect the supplied programmatic endpoint to its server with the given
configuration.
|
Session |
connectToServer(Class annotatedEndpointClass,
URI path)
Connect the supplied annotated endpoint to its server.
|
Session |
connectToServer(Endpoint endpointInstance,
ClientEndpointConfig cec,
URI path)
Connect the supplied programmatic client endpoint instance to its server
with the given configuration.
|
Session |
connectToServer(Object obj,
URI path)
Connect the supplied annotated endpoint instance to its server.
|
static ClientManager |
createClient()
Create new
ClientManager instance. |
static ClientManager |
createClient(String containerProviderClassName)
Create new ClientManager instance.
|
static ClientManager |
createClient(String containerProviderClassName,
WebSocketContainer webSocketContainer)
Create new ClientManager instance on top of provided
WebSocketContainer instance. |
static ClientManager |
createClient(WebSocketContainer webSocketContainer)
Create new ClientManager instance on top of provided
WebSocketContainer instance. |
long |
getDefaultAsyncSendTimeout()
Return the number of milliseconds the implementation will timeout
attempting to send a websocket message for all RemoteEndpoints associated
with this container.
|
int |
getDefaultMaxBinaryMessageBufferSize()
Returns the default maximum size of incoming binary message that this container
will buffer.
|
long |
getDefaultMaxSessionIdleTimeout()
Return the default time in milliseconds after which any web socket sessions in this
container will be closed if it has been inactive.
|
int |
getDefaultMaxTextMessageBufferSize()
Returns the default maximum size of incoming text message that this container
will buffer.
|
Set<Extension> |
getInstalledExtensions()
Return the set of Extensions installed in the container.
|
Map<String,Object> |
getProperties()
Container properties.
|
void |
setAsyncSendTimeout(long timeoutmillis)
Sets the number of milliseconds the implementation will timeout
attempting to send a websocket message for all RemoteEndpoints associated
with this container.
|
void |
setDefaultMaxBinaryMessageBufferSize(int i)
Sets the default maximum size of incoming binary message that this container
will buffer.
|
void |
setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout)
Sets the default time in milliseconds after which any web socket sessions in this
container will be closed if it has been inactive.
|
void |
setDefaultMaxTextMessageBufferSize(int i)
Sets the maximum size of incoming text message that this container
will buffer.
|
getExecutorService, getScheduledExecutorService, shutdown
public static final String HANDSHAKE_TIMEOUT
getProperties()
.
Value must be int
and represents handshake timeout in milliseconds. Default value is 30000 (30 seconds).public static final String RECONNECT_HANDLER
getProperties()
.
Value must be ClientManager.ReconnectHandler
instance.public ClientManager()
ClientManager
instance.
Uses CONTAINER_PROVIDER_CLASSNAME
as container implementation, thus relevant module needs to
be on classpath. Setting different container is possible via createClient(String)
}.createClient(String)
public static ClientManager createClient()
ClientManager
instance.
Uses CONTAINER_PROVIDER_CLASSNAME
as container implementation, thus relevant module needs to
be on classpath. Setting different container is possible via createClient(String)
.createClient(String)
public static ClientManager createClient(WebSocketContainer webSocketContainer)
WebSocketContainer
instance.
Uses CONTAINER_PROVIDER_CLASSNAME
as container implementation, thus relevant module needs to
be on classpath. Setting different container is possible via createClient(String)
.createClient(String)
public static ClientManager createClient(String containerProviderClassName)
public static ClientManager createClient(String containerProviderClassName, WebSocketContainer webSocketContainer)
WebSocketContainer
instance.public Session connectToServer(Class annotatedEndpointClass, URI path) throws DeploymentException, IOException
WebSocketContainer
ServerEndpoint
annotation. This method blocks until the connection
is established, or throws an error if either the connection could not be made or there
was a problem with the supplied endpoint class.connectToServer
in interface WebSocketContainer
annotatedEndpointClass
- the annotated websocket client endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the class is not a valid annotated endpoint class.IOException
- if there was a network or protocol problem that
prevented the client endpoint being connected to its server.public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException
WebSocketContainer
connectToServer
in interface WebSocketContainer
endpointClass
- the programmatic client endpoint class Endpoint
.cec
- the configuration used to configure the programmatic endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the configuration is not validIOException
- if there was a network or protocol problem that prevented the client endpoint being connected to its serverpublic Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException
WebSocketContainer
WebSocketContainer.connectToServer(java.lang.Class, javax.websocket.ClientEndpointConfig, java.net.URI)
instead.connectToServer
in interface WebSocketContainer
endpointInstance
- the programmatic client endpoint instance Endpoint
.cec
- the configuration used to configure the programmatic endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the configuration is not validIOException
- if there was a network or protocol problem that
prevented the client endpoint being connected to its serverpublic Session connectToServer(Object obj, URI path) throws DeploymentException, IOException
WebSocketContainer
ServerEndpoint
annotation. This method
blocks until the connection is established, or throws an error if either
the connection could not be made or there was a problem with the supplied
endpoint class. If the developer uses this method to deploy the client
endpoint, services like dependency injection that are supported, for
example, when the implementation is part of the Java EE platform
may not be available. If the client endpoint uses dependency injection,
use WebSocketContainer.connectToServer(java.lang.Class, java.net.URI)
instead.connectToServer
in interface WebSocketContainer
obj
- the annotated websocket client endpoint
instance.path
- the complete path to the server endpoint.DeploymentException
- if the annotated endpoint instance is not valid.IOException
- if there was a network or protocol problem that
prevented the client endpoint being connected to its server.public Future<Session> asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException
WebSocketContainer.connectToServer(Class, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same
applies to connecting etc.annotatedEndpointClass
- the annotated websocket client endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the class is not a valid annotated endpoint class.public Future<Session> asyncConnectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException
WebSocketContainer.connectToServer(Class, javax.websocket.ClientEndpointConfig, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same
applies to connecting etc.endpointClass
- the programmatic client endpoint class Endpoint
.path
- the complete path to the server endpoint.cec
- the configuration used to configure the programmatic endpoint.DeploymentException
- if the configuration is not validWebSocketContainer.connectToServer(Class, javax.websocket.ClientEndpointConfig, java.net.URI)
public Future<Session> asyncConnectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException
WebSocketContainer.connectToServer(javax.websocket.Endpoint, javax.websocket.ClientEndpointConfig, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same
applies to connecting etc.endpointInstance
- the programmatic client endpoint instance Endpoint
.path
- the complete path to the server endpoint.cec
- the configuration used to configure the programmatic endpoint.DeploymentException
- if the configuration is not validWebSocketContainer.connectToServer(javax.websocket.Endpoint, javax.websocket.ClientEndpointConfig, java.net.URI)
public Future<Session> asyncConnectToServer(Object obj, URI path) throws DeploymentException
WebSocketContainer.connectToServer(Object, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same
applies to connecting etc.obj
- the annotated websocket client endpoint
instance.path
- the complete path to the server endpoint.DeploymentException
- if the annotated endpoint instance is not valid.WebSocketContainer.connectToServer(Object, java.net.URI)
public int getDefaultMaxBinaryMessageBufferSize()
WebSocketContainer
Session.setMaxBinaryMessageBufferSize(int)
getDefaultMaxBinaryMessageBufferSize
in interface WebSocketContainer
public void setDefaultMaxBinaryMessageBufferSize(int i)
WebSocketContainer
setDefaultMaxBinaryMessageBufferSize
in interface WebSocketContainer
i
- the maximum size of binary message in number of bytes.public int getDefaultMaxTextMessageBufferSize()
WebSocketContainer
Session.setMaxTextMessageBufferSize(int)
getDefaultMaxTextMessageBufferSize
in interface WebSocketContainer
public void setDefaultMaxTextMessageBufferSize(int i)
WebSocketContainer
setDefaultMaxTextMessageBufferSize
in interface WebSocketContainer
i
- the maximum size of text message in number of bytes.public Set<Extension> getInstalledExtensions()
WebSocketContainer
getInstalledExtensions
in interface WebSocketContainer
public long getDefaultAsyncSendTimeout()
WebSocketContainer
getDefaultAsyncSendTimeout
in interface WebSocketContainer
public void setAsyncSendTimeout(long timeoutmillis)
WebSocketContainer
setAsyncSendTimeout
in interface WebSocketContainer
public long getDefaultMaxSessionIdleTimeout()
WebSocketContainer
Session.setMaxIdleTimeout(long)
getDefaultMaxSessionIdleTimeout
in interface WebSocketContainer
public void setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout)
WebSocketContainer
Session.setMaxIdleTimeout(long)
setDefaultMaxSessionIdleTimeout
in interface WebSocketContainer
defaultMaxSessionIdleTimeout
- the maximum time in milliseconds.public Map<String,Object> getProperties()
Copyright © 2012-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.