org.glassfish.grizzly.websockets
Interface WebSocket

All Known Implementing Classes:
BaseWebSocket, ClientWebSocket

public interface WebSocket

General WebSocket unit interface.

Author:
Alexey Stashok

Field Summary
static int END_POINT_GOING_DOWN
          Indicates that an endpoint is "going away", such as a server going down, or a browser having navigated away from a page.
static int INVALID_DATA
          Indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g.
static int MESSAGE_TOO_LARGE
          indicates that an endpoint is terminating the connection because it has received a message that is too large.
static int NORMAL_CLOSURE
          Indicates a normal closure, meaning whatever purpose the connection was established for has been fulfilled.
static int PROTOCOL_ERROR
          Indicates that an endpoint is terminating the connection due to a protocol error.
 
Method Summary
 boolean add(WebSocketListener listener)
           
 void close()
          Close the WebSocket.
 void close(int code)
           
 void close(int code, String reason)
           
 boolean isConnected()
           
 void onClose(DataFrame frame)
           
 void onConnect()
           
 void onMessage(byte[] bytes)
           
 void onMessage(String text)
           
 void onPing(DataFrame frame)
           
 boolean remove(WebSocketListener listener)
           
 GrizzlyFuture<DataFrame> send(byte[] data)
          Send a text frame
 GrizzlyFuture<DataFrame> send(String data)
          Send a text frame
 

Field Detail

NORMAL_CLOSURE

static final int NORMAL_CLOSURE
Indicates a normal closure, meaning whatever purpose the connection was established for has been fulfilled.

See Also:
Constant Field Values

END_POINT_GOING_DOWN

static final int END_POINT_GOING_DOWN
Indicates that an endpoint is "going away", such as a server going down, or a browser having navigated away from a page.

See Also:
Constant Field Values

PROTOCOL_ERROR

static final int PROTOCOL_ERROR
Indicates that an endpoint is terminating the connection due to a protocol error.

See Also:
Constant Field Values

INVALID_DATA

static final int INVALID_DATA
Indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g. an endpoint that understands only text data may send this if it receives a binary message.)

See Also:
Constant Field Values

MESSAGE_TOO_LARGE

static final int MESSAGE_TOO_LARGE
indicates that an endpoint is terminating the connection because it has received a message that is too large.

See Also:
Constant Field Values
Method Detail

send

GrizzlyFuture<DataFrame> send(String data)
Send a text frame

Returns:
GrizzlyFuture, which could be used to control the sending completion state.

send

GrizzlyFuture<DataFrame> send(byte[] data)
Send a text frame

Returns:
GrizzlyFuture, which could be used to control the sending completion state.

close

void close()
Close the WebSocket.


close

void close(int code)

close

void close(int code,
           String reason)

isConnected

boolean isConnected()

onConnect

void onConnect()

onMessage

void onMessage(String text)

onMessage

void onMessage(byte[] bytes)

onClose

void onClose(DataFrame frame)

onPing

void onPing(DataFrame frame)

add

boolean add(WebSocketListener listener)

remove

boolean remove(WebSocketListener listener)


Copyright © 2011 Oracle Corpration. All Rights Reserved.