public class WebSocketClient extends ContainerLifeCycle implements WebSocketContainerScope
AbstractLifeCycle.AbstractLifeCycleListener
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Constructor and Description |
---|
WebSocketClient()
Instantiate a WebSocketClient with defaults
|
WebSocketClient(ByteBufferPool bufferPool)
Create a new WebSocketClient
|
WebSocketClient(java.util.concurrent.Executor executor)
Create a new WebSocketClient
|
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)
Create a new WebSocketClient
|
WebSocketClient(SslContextFactory sslContextFactory,
java.util.concurrent.Executor executor)
Create a new WebSocketClient
|
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()
Get the internal
HttpClient . |
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()
Get the in use
SslContextFactory |
int |
hashCode() |
boolean |
isDispatchIO()
Deprecated.
|
boolean |
isStopAtShutdown() |
protected ConnectionManager |
newConnectionManager()
Deprecated.
has no replacement
|
void |
removeSessionListener(WebSocketSessionListener listener) |
void |
setAsyncWriteTimeout(long ms) |
void |
setBindAdddress(java.net.SocketAddress bindAddress)
Deprecated.
(this is a bad bad bad typo, it has 3
"d" characters in a row) use HttpClient.setBindAddress(SocketAddress)
to the internal WebSocketClient(HttpClient) |
void |
setBindAddress(java.net.SocketAddress bindAddress)
Sets the Bind Address on the internal
HttpClient . |
void |
setBufferPool(ByteBufferPool bufferPool)
Set's the Bind Address on the internal
HttpClient . |
void |
setConnectTimeout(long ms)
Set the timeout for connecting to the remote server on the internal
HttpClient |
void |
setCookieStore(java.net.CookieStore cookieStore)
Set the
CookieStore to use on the internal HttpClient |
void |
setDaemon(boolean daemon)
Deprecated.
not used, configure threading in
HttpClient instead |
void |
setDispatchIO(boolean dispatchIO)
Deprecated.
no longer used, this has no replacement
|
void |
setExecutor(java.util.concurrent.Executor executor)
Sets the Executor in use on the internal
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 classespublic WebSocketClient(SslContextFactory sslContextFactory)
sslContextFactory
- ssl context factory to use on the internal HttpClient
public WebSocketClient(java.util.concurrent.Executor executor)
executor
- the executor to use on the internal HttpClient
public WebSocketClient(ByteBufferPool bufferPool)
bufferPool
- byte buffer pool to use on the internal HttpClient
public WebSocketClient(SslContextFactory sslContextFactory, java.util.concurrent.Executor executor)
sslContextFactory
- ssl context factory to use on the internal HttpClient
executor
- the executor to use on the internal HttpClient
public 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()
SslContextFactory
getSslContextFactory
in interface WebSocketContainerScope
SslContextFactory
that manages TLS encryption on the internal HttpClient
WebSocketClient(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 setAsyncWriteTimeout(long ms)
@Deprecated public void setBindAdddress(java.net.SocketAddress bindAddress)
"d"
characters in a row) use HttpClient.setBindAddress(SocketAddress)
to the internal WebSocketClient(HttpClient)
bindAddress
- the address to bind to the internal HttpClient
public void setBindAddress(java.net.SocketAddress bindAddress)
HttpClient
.bindAddress
- the local bind address for the internal HttpClient
public void setBufferPool(ByteBufferPool bufferPool)
HttpClient
.bufferPool
- The buffer poolpublic void setConnectTimeout(long ms)
HttpClient
ms
- the timeout in millisecondspublic void setCookieStore(java.net.CookieStore cookieStore)
CookieStore
to use on the internal HttpClient
cookieStore
- The cookie store@Deprecated public void setDaemon(boolean daemon)
HttpClient
insteaddaemon
- do nothing@Deprecated public void setDispatchIO(boolean dispatchIO)
dispatchIO
- true to have IO operations be dispatched to Executorpublic void setExecutor(java.util.concurrent.Executor executor)
HttpClient
executor
- The executor to use@Deprecated public void setMasker(Masker masker)
masker
- does 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()
HttpClient
.
Note: this can result in a LinkageError
if used within a WebApp that runs
on a server that also has HttpClient
on the server classpath.
HttpClient
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–2019 Webtide. All rights reserved.