|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.tootallnate.websocket.WebSocket
public final class WebSocket
Represents one end (client or server) of a single WebSocket connection. Takes care of the "handshake" phase, then allows for easy sending of text frames, and recieving frames through an event-based model. This is an inner class, used by WebSocketClient and WebSocketServer, and should never need to be instantiated directly by your code. However, instances are exposed in WebSocketServer through the onClientOpen, onClientClose, onClientMessage callbacks.
Field Summary | |
---|---|
static byte |
CR
The byte representing CR, or Carriage Return, or \r |
static int |
DEFAULT_PORT
The default port of WebSockets, as defined in the spec. |
static byte |
END_OF_FRAME
The byte representing the end of a WebSocket text frame. |
static byte |
LF
The byte representing LF, or Line Feed, or \n |
static byte |
START_OF_FRAME
The byte representing the beginning of a WebSocket text frame. |
static java.nio.charset.Charset |
UTF8_CHARSET
The WebSocket protocol expects UTF-8 encoded bytes. |
Method Summary | |
---|---|
void |
close()
Closes the underlying SocketChannel, and calls the listener's onClose event handler. |
boolean |
send(java.lang.String text)
|
java.nio.channels.SocketChannel |
socketChannel()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
public static final java.nio.charset.Charset UTF8_CHARSET
public static final byte CR
public static final byte LF
public static final byte START_OF_FRAME
public static final byte END_OF_FRAME
Method Detail |
---|
public void close() throws java.io.IOException
java.io.IOException
- When socket related I/O errors occur.public boolean send(java.lang.String text) throws java.io.IOException
java.io.IOException
public java.nio.channels.SocketChannel socketChannel()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |