public class WebSocketClient extends ContainerLifeCycle implements WebSocketContainerScope, WebSocketSessionListener
AbstractLifeCycle.AbstractLifeCycleListener
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Constructor and Description |
---|
WebSocketClient()
Instantiate a WebSocketClient with defaults
|
WebSocketClient(ByteBufferPool bufferPool)
Deprecated.
use
WebSocketClient(HttpClient) instead |
WebSocketClient(java.util.concurrent.Executor executor)
Deprecated.
use
WebSocketClient(HttpClient) instead |
WebSocketClient(HttpClient httpClient)
Instantiate a WebSocketClient using HttpClient for defaults
|
WebSocketClient(HttpClient httpClient,
DecoratedObjectFactory objectFactory)
Instantiate a WebSocketClient using HttpClient for defaults
|
WebSocketClient(SslContextFactory sslContextFactory)
Deprecated.
use
WebSocketClient(HttpClient) instead |
WebSocketClient(SslContextFactory sslContextFactory,
java.util.concurrent.Executor executor)
Deprecated.
use
WebSocketClient(HttpClient) instead |
WebSocketClient(SslContextFactory sslContextFactory,
java.util.concurrent.Executor executor,
ByteBufferPool bufferPool)
Create WebSocketClient using sharing instances of SSLContextFactory
Executor, and ByteBufferPool
|
WebSocketClient(WebSocketContainerScope scope)
Create WebSocketClient other Container Scope, to allow sharing of
internal features like Executor, ByteBufferPool, SSLContextFactory, etc.
|
WebSocketClient(WebSocketContainerScope scope,
EventDriverFactory eventDriverFactory,
SessionFactory sessionFactory)
Create WebSocketClient based on pre-existing Container Scope, to allow sharing of
internal features like Executor, ByteBufferPool, SSLContextFactory, etc.
|
WebSocketClient(WebSocketContainerScope scope,
EventDriverFactory eventDriverFactory,
SessionFactory sessionFactory,
HttpClient httpClient)
Create WebSocketClient based on pre-existing Container Scope, to allow sharing of
internal features like Executor, ByteBufferPool, SSLContextFactory, etc.
|
WebSocketClient(WebSocketContainerScope scope,
SslContextFactory sslContextFactory)
Create WebSocketClient other Container Scope, to allow sharing of
internal features like Executor, ByteBufferPool, SSLContextFactory, etc.
|
Modifier and Type | Method and Description |
---|---|
void |
addSessionListener(WebSocketSessionListener listener) |
java.util.concurrent.Future<Session> |
connect(java.lang.Object websocket,
java.net.URI toUri) |
java.util.concurrent.Future<Session> |
connect(java.lang.Object websocket,
java.net.URI toUri,
ClientUpgradeRequest request)
Connect to remote websocket endpoint
|
java.util.concurrent.Future<Session> |
connect(java.lang.Object websocket,
java.net.URI toUri,
ClientUpgradeRequest request,
UpgradeListener upgradeListener)
Connect to remote websocket endpoint
|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
boolean |
equals(java.lang.Object o) |
long |
getAsyncWriteTimeout()
Return the number of milliseconds for a timeout of an attempted write operation.
|
java.net.SocketAddress |
getBindAddress() |
ByteBufferPool |
getBufferPool()
The configured Container Buffer Pool.
|
ConnectionManager |
getConnectionManager()
Deprecated.
|
long |
getConnectTimeout() |
java.net.CookieStore |
getCookieStore() |
EventDriverFactory |
getEventDriverFactory() |
java.util.concurrent.Executor |
getExecutor()
Executor in use by the container.
|
ExtensionFactory |
getExtensionFactory() |
HttpClient |
getHttpClient() |
Masker |
getMasker()
Deprecated.
not used, no replacement
|
int |
getMaxBinaryMessageBufferSize()
Get the maximum size for buffering of a binary message.
|
long |
getMaxBinaryMessageSize()
Get the maximum size for a binary message.
|
long |
getMaxIdleTimeout()
Get the max idle timeout for new connections.
|
int |
getMaxTextMessageBufferSize()
Get the maximum size for buffering of a text message.
|
long |
getMaxTextMessageSize()
Get the maximum size for a text message.
|
DecoratedObjectFactory |
getObjectFactory()
Object Factory used to create objects.
|
java.util.Set<WebSocketSession> |
getOpenSessions() |
WebSocketPolicy |
getPolicy()
The policy the container is running on.
|
Scheduler |
getScheduler() |
SessionFactory |
getSessionFactory() |
java.util.Collection<WebSocketSessionListener> |
getSessionListeners() |
SslContextFactory |
getSslContextFactory()
The SslContextFactory in use by the container.
|
int |
hashCode() |
boolean |
isDispatchIO()
Deprecated.
|
boolean |
isStopAtShutdown() |
protected ConnectionManager |
newConnectionManager()
Deprecated.
use HttpClient instead
|
void |
onSessionClosed(WebSocketSession session) |
void |
onSessionOpened(WebSocketSession session) |
void |
removeSessionListener(WebSocketSessionListener listener) |
void |
setAsyncWriteTimeout(long ms) |
void |
setBindAdddress(java.net.SocketAddress bindAddress)
Deprecated.
(this is a bad bad bad typo) use
HttpClient.setBindAddress(SocketAddress)
on instance passed to WebSocketClient(HttpClient) |
void |
setBindAddress(java.net.SocketAddress bindAddress)
Deprecated.
Use
HttpClient.setBindAddress(SocketAddress)
on instance passed to WebSocketClient(HttpClient) |
void |
setBufferPool(ByteBufferPool bufferPool)
Deprecated.
Use
HttpClient.setByteBufferPool(ByteBufferPool)
on the instance passed to WebSocketClient(HttpClient) |
void |
setConnectTimeout(long ms)
Deprecated.
Use
HttpClient.setConnectTimeout(long)
on the instance passed to WebSocketClient(HttpClient) |
void |
setCookieStore(java.net.CookieStore cookieStore)
Deprecated.
Use
HttpClient.setCookieStore(CookieStore) on the HttpClient instance passed
to WebSocketClient(HttpClient) |
void |
setDaemon(boolean daemon)
Deprecated.
not used, configure threading in HttpClient instead
|
void |
setDispatchIO(boolean dispatchIO)
Deprecated.
|
void |
setExecutor(java.util.concurrent.Executor executor)
Deprecated.
Use
HttpClient.setExecutor(Executor)
on the instance passed to WebSocketClient(HttpClient) |
void |
setMasker(Masker masker)
Deprecated.
not used, no replacement
|
void |
setMaxBinaryMessageBufferSize(int max) |
void |
setMaxIdleTimeout(long ms)
Set the max idle timeout for new connections.
|
void |
setMaxTextMessageBufferSize(int max) |
void |
setStopAtShutdown(boolean stop)
Set JVM shutdown behavior.
|
java.lang.String |
toString() |
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isRunning
dumpObjects, dumpSelf
public WebSocketClient()
public WebSocketClient(HttpClient httpClient)
httpClient
- the HttpClient to base internal defaults off ofpublic WebSocketClient(HttpClient httpClient, DecoratedObjectFactory objectFactory)
httpClient
- the HttpClient to base internal defaults off ofobjectFactory
- the DecoratedObjectFactory for all client instantiated classes@Deprecated public WebSocketClient(SslContextFactory sslContextFactory)
WebSocketClient(HttpClient)
insteadsslContextFactory
- ssl context factory to usepublic WebSocketClient(java.util.concurrent.Executor executor)
WebSocketClient(HttpClient)
insteadexecutor
- the executor to use@Deprecated public WebSocketClient(ByteBufferPool bufferPool)
WebSocketClient(HttpClient)
insteadbufferPool
- byte buffer pool to use@Deprecated public WebSocketClient(SslContextFactory sslContextFactory, java.util.concurrent.Executor executor)
WebSocketClient(HttpClient)
insteadsslContextFactory
- ssl context factory to useexecutor
- the executor to usepublic WebSocketClient(WebSocketContainerScope scope)
scope
- the Container Scopepublic WebSocketClient(WebSocketContainerScope scope, SslContextFactory sslContextFactory)
scope
- the Container ScopesslContextFactory
- SSL ContextFactory to use in preference to one from
WebSocketContainerScope.getSslContextFactory()
public WebSocketClient(SslContextFactory sslContextFactory, java.util.concurrent.Executor executor, ByteBufferPool bufferPool)
sslContextFactory
- shared SSL ContextFactoryexecutor
- shared ExecutorbufferPool
- shared ByteBufferPoolpublic WebSocketClient(WebSocketContainerScope scope, EventDriverFactory eventDriverFactory, SessionFactory sessionFactory)
scope
- the Container ScopeeventDriverFactory
- the EventDriver Factory to usesessionFactory
- the SessionFactory to usepublic WebSocketClient(WebSocketContainerScope scope, EventDriverFactory eventDriverFactory, SessionFactory sessionFactory, HttpClient httpClient)
scope
- the Container ScopeeventDriverFactory
- the EventDriver Factory to usesessionFactory
- the SessionFactory to usehttpClient
- the httpClient to usepublic java.util.concurrent.Future<Session> connect(java.lang.Object websocket, java.net.URI toUri) throws java.io.IOException
java.io.IOException
public java.util.concurrent.Future<Session> connect(java.lang.Object websocket, java.net.URI toUri, ClientUpgradeRequest request) throws java.io.IOException
websocket
- the websocket objecttoUri
- the websocket uri to connect torequest
- the upgrade request informationjava.io.IOException
- if unable to connectpublic java.util.concurrent.Future<Session> connect(java.lang.Object websocket, java.net.URI toUri, ClientUpgradeRequest request, UpgradeListener upgradeListener) throws java.io.IOException
websocket
- the websocket objecttoUri
- the websocket uri to connect torequest
- the upgrade request informationupgradeListener
- the upgrade listenerjava.io.IOException
- if unable to connectprotected void doStart() throws java.lang.Exception
ContainerLifeCycle
doStart
in class ContainerLifeCycle
java.lang.Exception
protected void doStop() throws java.lang.Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
java.lang.Exception
@Deprecated public boolean isDispatchIO()
public long getAsyncWriteTimeout()
public java.net.SocketAddress getBindAddress()
public ByteBufferPool getBufferPool()
WebSocketContainerScope
getBufferPool
in interface WebSocketContainerScope
@Deprecated public ConnectionManager getConnectionManager()
public long getConnectTimeout()
public java.net.CookieStore getCookieStore()
public EventDriverFactory getEventDriverFactory()
public java.util.concurrent.Executor getExecutor()
WebSocketContainerScope
getExecutor
in interface WebSocketContainerScope
public ExtensionFactory getExtensionFactory()
@Deprecated public Masker getMasker()
RandomMasker
instancepublic int getMaxBinaryMessageBufferSize()
public long getMaxBinaryMessageSize()
public long getMaxIdleTimeout()
public int getMaxTextMessageBufferSize()
public long getMaxTextMessageSize()
public DecoratedObjectFactory getObjectFactory()
WebSocketContainerScope
getObjectFactory
in interface WebSocketContainerScope
public java.util.Set<WebSocketSession> getOpenSessions()
public WebSocketPolicy getPolicy()
WebSocketContainerScope
getPolicy
in interface WebSocketContainerScope
public Scheduler getScheduler()
public SessionFactory getSessionFactory()
public SslContextFactory getSslContextFactory()
WebSocketContainerScope
getSslContextFactory
in interface WebSocketContainerScope
SslContextFactory
that manages TLS encryptionWebSocketClient(SslContextFactory)
public void addSessionListener(WebSocketSessionListener listener)
addSessionListener
in interface WebSocketContainerScope
public void removeSessionListener(WebSocketSessionListener listener)
removeSessionListener
in interface WebSocketContainerScope
public java.util.Collection<WebSocketSessionListener> getSessionListeners()
getSessionListeners
in interface WebSocketContainerScope
@Deprecated protected ConnectionManager newConnectionManager()
public void onSessionClosed(WebSocketSession session)
onSessionClosed
in interface WebSocketSessionListener
public void onSessionOpened(WebSocketSession session)
onSessionOpened
in interface WebSocketSessionListener
public void setAsyncWriteTimeout(long ms)
@Deprecated public void setBindAdddress(java.net.SocketAddress bindAddress)
HttpClient.setBindAddress(SocketAddress)
on instance passed to WebSocketClient(HttpClient)
bindAddress
- the address to bind to@Deprecated public void setBindAddress(java.net.SocketAddress bindAddress)
HttpClient.setBindAddress(SocketAddress)
on instance passed to WebSocketClient(HttpClient)
bindAddress
- the address to bind topublic void setBufferPool(ByteBufferPool bufferPool)
HttpClient.setByteBufferPool(ByteBufferPool)
on the instance passed to WebSocketClient(HttpClient)
bufferPool
- The buffer poolpublic void setConnectTimeout(long ms)
HttpClient.setConnectTimeout(long)
on the instance passed to WebSocketClient(HttpClient)
ms
- the timeout in millisecondspool@Deprecated public void setCookieStore(java.net.CookieStore cookieStore)
HttpClient.setCookieStore(CookieStore)
on the HttpClient instance passed
to WebSocketClient(HttpClient)
cookieStore
- The cookie store@Deprecated public void setDaemon(boolean daemon)
daemon
- do nothing@Deprecated public void setDispatchIO(boolean dispatchIO)
@Deprecated public void setExecutor(java.util.concurrent.Executor executor)
HttpClient.setExecutor(Executor)
on the instance passed to WebSocketClient(HttpClient)
executor
- The executor to use@Deprecated public void setMasker(Masker masker)
masker
- do nothingpublic void setMaxBinaryMessageBufferSize(int max)
public void setMaxIdleTimeout(long ms)
Existing connections will not have their max idle timeout adjusted.
ms
- the timeout in millisecondspublic void setMaxTextMessageBufferSize(int max)
public HttpClient getHttpClient()
public void setStopAtShutdown(boolean stop)
stop
- If true, this client instance will be explicitly stopped when the
JVM is shutdown. Otherwise the application is responsible for maintaining the WebSocketClient lifecycle.Runtime.addShutdownHook(Thread)
,
ShutdownThread
public boolean isStopAtShutdown()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class AbstractLifeCycle
Copyright © 1995–2023 Webtide. All rights reserved.