org.glassfish.grizzly.websockets
Class WebSocketClientHandler<W extends WebSocket>

java.lang.Object
  extended by org.glassfish.grizzly.websockets.WebSocketClientHandler<W>
All Implemented Interfaces:
WebSocketHandler<W>

public abstract class WebSocketClientHandler<W extends WebSocket>
extends Object
implements WebSocketHandler<W>

Abstract client-side WebSocketHandler, which will handle client WebSockets events.

Author:
Alexey Stashok
See Also:
WebSocketHandler, WebSocketApplication

Constructor Summary
WebSocketClientHandler()
           
 
Method Summary
protected  W createWebSocket(Connection connection, ClientWebSocketMeta meta)
          Method is called before the WebSocketEngine will create a client-side WebSocket object, so the handler may return any customized subtype of WebSocket.
protected  void handshake(W socket, ServerWebSocketMeta serverMeta)
          Method is called, when inital WebSocket handshake process was completed, but WebSocketClientHandler may perform additional validation.
abstract  void onConnect(W websocket)
          The method is called, when client-side WebSocket gets connected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.glassfish.grizzly.websockets.WebSocketHandler
onClose, onMessage
 

Constructor Detail

WebSocketClientHandler

public WebSocketClientHandler()
Method Detail

onConnect

public abstract void onConnect(W websocket)
                        throws IOException
The method is called, when client-side WebSocket gets connected. Usually this method is called right after client-server handshake validatation is completed.

Parameters:
websocket - connected WebSocket.
Throws:
IOException

handshake

protected void handshake(W socket,
                         ServerWebSocketMeta serverMeta)
                  throws HandshakeException
Method is called, when inital WebSocket handshake process was completed, but WebSocketClientHandler may perform additional validation.

Parameters:
socket - WebSocket
serverMeta - ServerWebSocketMeta.
Throws:
HandshakeException - error, occurred during the handshake.

createWebSocket

protected W createWebSocket(Connection connection,
                            ClientWebSocketMeta meta)
Method is called before the WebSocketEngine will create a client-side WebSocket object, so the handler may return any customized subtype of WebSocket.

Parameters:
connection - underlying Grizzly Connection.
meta - client-side WebSocketMeta.
Returns:
customized WebSocket, or null, if handler wants to delegate WebSocket creation to WebSocketEngine.


Copyright © 2010 Oracle Corpration. All Rights Reserved.