com.sun.grizzly.websockets
Interface WebSocket

All Known Implementing Classes:
BaseServerWebSocket, BaseWebSocket, ChatWebSocket, ClientWebSocket

public interface WebSocket


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()
           
 void close(int code)
           
 void close(int code, String reason)
           
 boolean isConnected()
           
 void onClose(DataFrame frame)
           
 void onConnect()
           
 void onFragment(boolean last, byte[] binaryPayload)
           
 void onMessage(byte[] data)
           
 void onMessage(String text)
           
 void onPing(DataFrame frame)
           
 void onPong(DataFrame frame)
           
 boolean remove(WebSocketListener listener)
           
 void send(byte[] data)
           
 void send(String data)
          Write the data to the socket.
 void stream(boolean last, byte[] bytes, int off, int len)
           
 

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

void send(String data)
Write the data to the socket. This text will be converted to a UTF-8 encoded byte[] prior to sending.

Parameters:
data -
Throws:
IOException

send

void send(byte[] data)

close

void close()

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[] data)

onClose

void onClose(DataFrame frame)

onPing

void onPing(DataFrame frame)

onPong

void onPong(DataFrame frame)

onFragment

void onFragment(boolean last,
                byte[] binaryPayload)

add

boolean add(WebSocketListener listener)

remove

boolean remove(WebSocketListener listener)

stream

void stream(boolean last,
            byte[] bytes,
            int off,
            int len)


Copyright © 2012 Oracle Corporation. All Rights Reserved.