|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.java_websocket.WebSocketImpl
public class WebSocketImpl
Represents one end (client or server) of a single WebSocketImpl connection. Takes care of the "handshake" phase, then allows for easy sending of text frames, and receiving frames through an event-based model.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.java_websocket.WebSocket |
---|
WebSocket.READYSTATE, WebSocket.Role |
Field Summary | |
---|---|
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. |
Fields inherited from interface org.java_websocket.WebSocket |
---|
DEFAULT_PORT, DEFAULT_WSS_PORT |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int RCVBUF
public static boolean DEBUG
public static final List<Draft> defaultdraftlist
public SelectionKey key
public ByteChannel channel
key
public final BlockingQueue<ByteBuffer> outQueue
public final BlockingQueue<ByteBuffer> inQueue
public volatile WebSocketServer.WebSocketWorker workerThread
Constructor Detail |
---|
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)
Method Detail |
---|
public void decode(ByteBuffer socketBuffer)
public void close(int code, String message)
WebSocket
close
in interface 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(int code)
close
in interface WebSocket
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 void sendFrame(Framedata framedata)
sendFrame
in interface WebSocket
public boolean hasBufferedData()
hasBufferedData
in interface WebSocket
public void startHandshake(ClientHandshakeBuilder handshakedata) throws InvalidHandshakeException
InvalidHandshakeException
public boolean isConnecting()
isConnecting
in interface WebSocket
public boolean isOpen()
isOpen
in interface WebSocket
public boolean isClosing()
isClosing
in interface WebSocket
public boolean isFlushAndClose()
WebSocket
isFlushAndClose
in interface WebSocket
public boolean isClosed()
WebSocket
isClosed
in interface WebSocket
public WebSocket.READYSTATE getReadyState()
WebSocket
getReadyState
in interface WebSocket
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public InetSocketAddress getRemoteSocketAddress()
getRemoteSocketAddress
in interface WebSocket
public InetSocketAddress getLocalSocketAddress()
getLocalSocketAddress
in interface WebSocket
public Draft getDraft()
getDraft
in interface WebSocket
public void close()
WebSocket
close
in interface WebSocket
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |