org.webbitserver.netty
Class WebSocketClient

java.lang.Object
  extended by org.webbitserver.netty.WebSocketClient
All Implemented Interfaces:
Endpoint<WebSocket>, WebSocket

public class WebSocketClient
extends Object
implements WebSocket


Constructor Summary
WebSocketClient(URI uri, WebSocketHandler webSocketHandler)
           
WebSocketClient(URI uri, WebSocketHandler webSocketHandler, Executor executor)
           
 
Method Summary
 WebSocketClient connectionExceptionHandler(Thread.UncaughtExceptionHandler handler)
          What to do when an exception occurs when attempting to read/write data from/to the underlying connection.
 WebSocketClient cookie(HttpCookie httpCookie)
           
 Executor getExecutor()
          Get main work executor that all handlers will execute on.
 URI getUri()
          Get base URI that endpoint is serving on (or connected to).
 WebSocketClient reconnectEvery(long reconnectIntervalMillis)
           
 WebSocketClient setupSsl(InputStream keyStore, String storePass)
          Setup SSL/TLS handler

This is shortcut for setupSsl(keyStore, pass, pass).

 Future<WebSocketClient> start()
          Start in background.
 Future<WebSocketClient> stop()
          Stop in background.
 WebSocketClient uncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
          What to do when an exception gets thrown in a handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebSocketClient

public WebSocketClient(URI uri,
                       WebSocketHandler webSocketHandler)

WebSocketClient

public WebSocketClient(URI uri,
                       WebSocketHandler webSocketHandler,
                       Executor executor)
Method Detail

cookie

public WebSocketClient cookie(HttpCookie httpCookie)

uncaughtExceptionHandler

public WebSocketClient uncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
Description copied from interface: Endpoint
What to do when an exception gets thrown in a handler.

Defaults to using PrintStackTraceExceptionHandler. It is suggested that apps supply their own implementation (e.g. to log somewhere).

Specified by:
uncaughtExceptionHandler in interface Endpoint<WebSocket>

connectionExceptionHandler

public WebSocketClient connectionExceptionHandler(Thread.UncaughtExceptionHandler handler)
Description copied from interface: Endpoint
What to do when an exception occurs when attempting to read/write data from/to the underlying connection. e.g. If an HTTP request disconnects before it was expected.

Defaults to using SilentExceptionHandler as this is a common thing to happen on a network, and most systems should not care.

Specified by:
connectionExceptionHandler in interface Endpoint<WebSocket>

getExecutor

public Executor getExecutor()
Description copied from interface: Endpoint
Get main work executor that all handlers will execute on.

Specified by:
getExecutor in interface Endpoint<WebSocket>

getUri

public URI getUri()
Description copied from interface: Endpoint
Get base URI that endpoint is serving on (or connected to).

Specified by:
getUri in interface Endpoint<WebSocket>

setupSsl

public WebSocketClient setupSsl(InputStream keyStore,
                                String storePass)
Description copied from interface: Endpoint
Setup SSL/TLS handler

This is shortcut for setupSsl(keyStore, pass, pass).

Specified by:
setupSsl in interface Endpoint<WebSocket>
Parameters:
keyStore - Keystore InputStream
storePass - Store and key password
Returns:
current WebServer instance
See Also:
#setupSsl(String, String, String)

start

public Future<WebSocketClient> start()
Description copied from interface: Endpoint
Start in background. This returns immediately, but the endpoint may still not be ready to accept incoming requests (or have established a connection - if this is a client). To wait until it's fully started, call Future.get() on the returned future.

Specified by:
start in interface Endpoint<WebSocket>

stop

public Future<WebSocketClient> stop()
Description copied from interface: Endpoint
Stop in background. This returns immediately, but the endpoint may still be shutting down. To wait until it's fully stopped, call Future.get() on the returned future.

Specified by:
stop in interface Endpoint<WebSocket>

reconnectEvery

public WebSocketClient reconnectEvery(long reconnectIntervalMillis)
Specified by:
reconnectEvery in interface WebSocket


Copyright © 2012. All Rights Reserved.