org.glassfish.grizzly.websockets
Class WebSocketBase

java.lang.Object
  extended by org.glassfish.grizzly.websockets.WebSocketBase
All Implemented Interfaces:
WebSocket

public class WebSocketBase
extends Object
implements WebSocket

The WebSocket base implementation.

Author:
Alexey Stashok
See Also:
WebSocket

Field Summary
protected  Connection connection
           
protected  WebSocketHandler handler
           
protected  WebSocketMeta meta
           
 
Constructor Summary
WebSocketBase(Connection connection, WebSocketMeta meta, WebSocketHandler handler)
          Construct a WebSocketBase.
 
Method Summary
 void close()
          Close the WebSocket.
 Connection getConnection()
          Gets the WebSocket's underlying Connection.
 WebSocketHandler getHandler()
          Returns the WebSocket's events handler.
 WebSocketMeta getMeta()
          Returns the WebSocket's meta data.
 URI getURI()
          Gets the WebSocket URI.
 boolean isConnected()
          Returns true if the WebSocket is connected and ready to operate, or false otherwise.
 GrizzlyFuture<Frame> send(Frame frame)
          Send a message, represented as WebSocket Frame.
 GrizzlyFuture<Frame> send(Frame frame, CompletionHandler<Frame> completionHandler)
          Send a message, represented as WebSocket Frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

meta

protected final WebSocketMeta meta

connection

protected final Connection connection

handler

protected final WebSocketHandler handler
Constructor Detail

WebSocketBase

public WebSocketBase(Connection connection,
                     WebSocketMeta meta,
                     WebSocketHandler handler)
Construct a WebSocketBase.

Parameters:
connection - underlying Grizzly Connection.
meta - WebSocketMeta info
Method Detail

getURI

public URI getURI()
Gets the WebSocket URI.

Specified by:
getURI in interface WebSocket
Returns:
the WebSocket URI.

getMeta

public WebSocketMeta getMeta()
Returns the WebSocket's meta data.

Specified by:
getMeta in interface WebSocket
Returns:
WebSocketMeta.

getHandler

public WebSocketHandler getHandler()
Returns the WebSocket's events handler.

Specified by:
getHandler in interface WebSocket
Returns:
WebSocketHandler.

getConnection

public Connection getConnection()
Gets the WebSocket's underlying Connection.

Specified by:
getConnection in interface WebSocket
Returns:
the WebSocket's underlying Connection.

send

public final GrizzlyFuture<Frame> send(Frame frame)
                                throws IOException
Send a message, represented as WebSocket Frame.

Specified by:
send in interface WebSocket
Parameters:
frame - Frame.
Returns:
GrizzlyFuture, which could be used to control the sending completion state.
Throws:
IOException

send

public GrizzlyFuture<Frame> send(Frame frame,
                                 CompletionHandler<Frame> completionHandler)
                          throws IOException
Send a message, represented as WebSocket Frame.

Specified by:
send in interface WebSocket
Parameters:
frame - Frame.
completionHandler - CompletionHandler, which could be used to control the message sending state.
Returns:
GrizzlyFuture, which could be used to control the sending completion state.
Throws:
IOException

close

public void close()
           throws IOException
Close the WebSocket. The close operation will do the following steps: 1) try to send a close frame 2) call WebSocketHandler.onClose(org.glassfish.grizzly.websockets.WebSocket) method 3) close the underlying Connection

Specified by:
close in interface WebSocket
Throws:
IOException

isConnected

public boolean isConnected()
Returns true if the WebSocket is connected and ready to operate, or false otherwise.

Specified by:
isConnected in interface WebSocket
Returns:
true if the WebSocket is connected and ready to operate, or false otherwise.


Copyright © 2010 Oracle Corpration. All Rights Reserved.