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
key
public 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)
WebSocket
protected 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)
WebSocket
closeConnection
in interface WebSocket
protected 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 WebSocket
IllegalArgumentException
NotYetConnectedException
WebsocketNotConnectedException
public void send(ByteBuffer bytes) throws IllegalArgumentException, WebsocketNotConnectedException
send
in interface WebSocket
IllegalArgumentException
NotYetConnectedException
WebsocketNotConnectedException
public void send(byte[] bytes) throws IllegalArgumentException, WebsocketNotConnectedException
send
in interface WebSocket
IllegalArgumentException
WebsocketNotConnectedException
public boolean hasBufferedData()
hasBufferedData
in interface WebSocket
public void startHandshake(ClientHandshakeBuilder handshakedata) throws InvalidHandshakeException
InvalidHandshakeException
public boolean isConnecting()
isConnecting
in interface WebSocket
public boolean isFlushAndClose()
WebSocket
isFlushAndClose
in interface WebSocket
public boolean isClosed()
WebSocket
public WebSocket.READYSTATE getReadyState()
WebSocket
getReadyState
in interface WebSocket
public InetSocketAddress getRemoteSocketAddress()
getRemoteSocketAddress
in interface WebSocket
public InetSocketAddress getLocalSocketAddress()
getLocalSocketAddress
in interface WebSocket
Copyright © 2013. All Rights Reserved.