public class WebSocketImpl extends Object implements WebSocket
WebSocket.READYSTATE, WebSocket.Role| Modifier and Type | Field and Description |
|---|---|
ByteChannel |
channel
the possibly wrapped channel object whose selection is controlled by
key |
static boolean |
DEBUG |
static List<Draft> |
defaultdraftlist |
BlockingQueue<ByteBuffer> |
inQueue
Queue of buffers that need to be processed
|
SelectionKey |
key |
BlockingQueue<ByteBuffer> |
outQueue
Queue of buffers that need to be sent to the client.
|
static int |
RCVBUF |
WebSocketServer.WebSocketWorker |
workerThread
Helper variable meant to store the thread which ( exclusively ) triggers this objects decode method.
|
DEFAULT_PORT, DEFAULT_WSS_PORT| Constructor and Description |
|---|
WebSocketImpl(WebSocketListener listener,
Draft draft)
crates a websocket with client role
|
WebSocketImpl(WebSocketListener listener,
Draft draft,
Socket socket)
Deprecated.
|
WebSocketImpl(WebSocketListener listener,
List<Draft> drafts)
crates a websocket with server role
|
WebSocketImpl(WebSocketListener listener,
List<Draft> drafts,
Socket socket)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Convenience function which behaves like close(CloseFrame.NORMAL)
|
void |
close(int code) |
void |
close(int code,
String message)
sends the closing handshake.
|
void |
close(InvalidDataException e) |
void |
closeConnection() |
protected void |
closeConnection(int code,
boolean remote) |
void |
closeConnection(int code,
String message)
This will close the connection immediately without a proper close handshake.
|
protected void |
closeConnection(int code,
String message,
boolean remote) |
void |
decode(ByteBuffer socketBuffer) |
void |
eot() |
protected void |
flushAndClose(int code,
String message,
boolean remote) |
Draft |
getDraft() |
InetSocketAddress |
getLocalSocketAddress() |
WebSocket.READYSTATE |
getReadyState()
Retrieve the WebSocket 'readyState'.
|
InetSocketAddress |
getRemoteSocketAddress() |
boolean |
hasBufferedData() |
int |
hashCode() |
boolean |
isClosed()
Returns whether the close handshake has been completed and the socket is closed.
|
boolean |
isClosing() |
boolean |
isConnecting() |
boolean |
isFlushAndClose()
Returns true when no further frames may be submitted
This happens before the socket connection is closed. |
boolean |
isOpen() |
void |
send(byte[] bytes) |
void |
send(ByteBuffer bytes)
Send Binary data (plain bytes) to the other end.
|
void |
send(String text)
Send Text data to the other end.
|
void |
sendFrame(Framedata framedata) |
void |
startHandshake(ClientHandshakeBuilder handshakedata) |
String |
toString() |
public static int RCVBUF
public static boolean DEBUG
public SelectionKey key
public ByteChannel channel
keypublic final BlockingQueue<ByteBuffer> outQueue
public final BlockingQueue<ByteBuffer> inQueue
public volatile WebSocketServer.WebSocketWorker workerThread
public WebSocketImpl(WebSocketListener listener, List<Draft> drafts)
public WebSocketImpl(WebSocketListener listener, Draft draft)
socket - may be unbound@Deprecated public WebSocketImpl(WebSocketListener listener, Draft draft, Socket socket)
@Deprecated public WebSocketImpl(WebSocketListener listener, List<Draft> drafts, Socket socket)
public void decode(ByteBuffer socketBuffer)
public void close(int code,
String message)
WebSocketprotected void closeConnection(int code,
String message,
boolean remote)
remote - Indicates who "generated" code.true means that this endpoint received the code from the other endpoint.remote may also be true if this endpoint started the closing handshake since the other endpoint may not simply echo the code but close the connection the same time this endpoint does do but with an other code. protected void closeConnection(int code,
boolean remote)
public void closeConnection()
public void closeConnection(int code,
String message)
WebSocketcloseConnection in interface WebSocketprotected void flushAndClose(int code,
String message,
boolean remote)
public void eot()
public void close(InvalidDataException e)
public void send(String text) throws WebsocketNotConnectedException
send in interface WebSocketIllegalArgumentExceptionNotYetConnectedExceptionWebsocketNotConnectedExceptionpublic void send(ByteBuffer bytes) throws IllegalArgumentException, WebsocketNotConnectedException
send in interface WebSocketIllegalArgumentExceptionNotYetConnectedExceptionWebsocketNotConnectedExceptionpublic void send(byte[] bytes)
throws IllegalArgumentException,
WebsocketNotConnectedException
send in interface WebSocketIllegalArgumentExceptionWebsocketNotConnectedExceptionpublic boolean hasBufferedData()
hasBufferedData in interface WebSocketpublic void startHandshake(ClientHandshakeBuilder handshakedata) throws InvalidHandshakeException
InvalidHandshakeExceptionpublic boolean isConnecting()
isConnecting in interface WebSocketpublic boolean isFlushAndClose()
WebSocketisFlushAndClose in interface WebSocketpublic boolean isClosed()
WebSocketpublic WebSocket.READYSTATE getReadyState()
WebSocketgetReadyState in interface WebSocketpublic InetSocketAddress getRemoteSocketAddress()
getRemoteSocketAddress in interface WebSocketpublic InetSocketAddress getLocalSocketAddress()
getLocalSocketAddress in interface WebSocketCopyright © 2013. All Rights Reserved.