org.glassfish.grizzly.websockets
Interface WebSocket

All Known Implementing Classes:
DefaultWebSocket, WebSocketClient

public interface WebSocket

General WebSocket unit interface.

Author:
Alexey Stashok

Field Summary
static int ABNORMAL_CLOSE
          a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
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 NO_STATUS_CODE
          a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
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()
           
 void close(int code)
           
 void close(int code, java.lang.String reason)
           
 boolean isConnected()
           
 void onClose(DataFrame frame)
           
 void onConnect()
           
 void onFragment(boolean last, byte[] payload)
           
 void onFragment(boolean last, java.lang.String payload)
           
 void onMessage(byte[] data)
           
 void onMessage(java.lang.String text)
           
 void onPing(DataFrame frame)
           
 void onPong(DataFrame frame)
           
 boolean remove(WebSocketListener listener)
           
 GrizzlyFuture<DataFrame> send(byte[] data)
          Send a text frame
 GrizzlyFuture<DataFrame> send(java.lang.String data)
          Send a text frame
 GrizzlyFuture<DataFrame> stream(boolean last, byte[] fragment, int off, int len)
           
 GrizzlyFuture<DataFrame> stream(boolean last, java.lang.String fragment)
           
 

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

NO_STATUS_CODE

static final int NO_STATUS_CODE
a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that no status code was actually present.

See Also:
Constant Field Values

ABNORMAL_CLOSE

static final int ABNORMAL_CLOSE
a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g. without sending or receiving a Close control frame.

See Also:
Constant Field Values
Method Detail

send

GrizzlyFuture<DataFrame> send(java.lang.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.

stream

GrizzlyFuture<DataFrame> stream(boolean last,
                                java.lang.String fragment)

stream

GrizzlyFuture<DataFrame> stream(boolean last,
                                byte[] fragment,
                                int off,
                                int len)

close

void close()

close

void close(int code)

close

void close(int code,
           java.lang.String reason)

isConnected

boolean isConnected()

onConnect

void onConnect()

onMessage

void onMessage(java.lang.String text)

onMessage

void onMessage(byte[] data)

onFragment

void onFragment(boolean last,
                java.lang.String payload)

onFragment

void onFragment(boolean last,
                byte[] payload)

onClose

void onClose(DataFrame frame)

onPing

void onPing(DataFrame frame)

onPong

void onPong(DataFrame frame)

add

boolean add(WebSocketListener listener)

remove

boolean remove(WebSocketListener listener)


Copyright © 2011 Oracle Corpration. All Rights Reserved.