-
public interface WebSocket
-
-
Method Summary
Modifier and Type Method Description abstract void
close(int code, String message)
sends the closing handshake. abstract void
close(int code)
sends the closing handshake. abstract void
close()
Convenience function which behaves like close(CloseFrame. abstract void
closeConnection(int code, String message)
This will close the connection immediately without a proper close handshake. abstract void
send(String text)
Send Text data to the other end. abstract void
send(ByteBuffer bytes)
Send Binary data (plain bytes) to the other end. abstract void
send(Array<byte> bytes)
Send Binary data (plain bytes) to the other end. abstract void
sendFrame(Framedata framedata)
Send a frame to the other end abstract void
sendFrame(Collection<Framedata> frames)
Send a collection of frames to the other end abstract void
sendPing()
Send a ping to the other end abstract void
sendFragmentedFrame(Opcode op, ByteBuffer buffer, boolean fin)
Allows to send continuous/fragmented frames conveniently. abstract boolean
hasBufferedData()
Checks if the websocket has buffered data abstract InetSocketAddress
getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or {@code null}
if it isunconnected.abstract InetSocketAddress
getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to. abstract boolean
isOpen()
Is the websocket in the state OPEN abstract boolean
isClosing()
Is the websocket in the state CLOSING abstract boolean
isFlushAndClose()
Returns true when no further frames may be submitted This happens before the socketconnection is closed. abstract boolean
isClosed()
Is the websocket in the state CLOSED abstract Draft
getDraft()
Getter for the draft abstract ReadyState
getReadyState()
Retrieve the WebSocket 'ReadyState'. abstract String
getResourceDescriptor()
Returns the HTTP Request-URI as defined by http://tools.ietf.org/html/rfc2616#section-5.1. abstract <T> void
setAttachment(T attachment)
Setter for an attachment on the socket connection. abstract <T> T
getAttachment()
Getter for the connection attachment. abstract boolean
hasSSLSupport()
Does this websocket use an encrypted (wss/ssl) or unencrypted (ws) connection abstract SSLSession
getSSLSession()
Returns the ssl session of websocket, if ssl/wss is used for this instance. abstract IProtocol
getProtocol()
Returns the used Sec-WebSocket-Protocol for this websocket connection -
-
Method Detail
-
close
abstract void close(int code, String message)
sends the closing handshake. may be send in response to an other handshake.
- Parameters:
code
- the closing codemessage
- the closing message
-
close
abstract void close(int code)
sends the closing handshake. may be send in response to an other handshake.
- Parameters:
code
- the closing code
-
close
abstract void close()
Convenience function which behaves like close(CloseFrame.NORMAL)
-
closeConnection
abstract void closeConnection(int code, String message)
This will close the connection immediately without a proper close handshake. The code and themessage therefore won't be transferred over the wire also they will be forwarded toonClose/onWebsocketClose.
- Parameters:
code
- the closing codemessage
- the closing message
-
send
abstract void send(String text)
Send Text data to the other end.
- Parameters:
text
- the text data to send
-
send
abstract void send(ByteBuffer bytes)
Send Binary data (plain bytes) to the other end.
- Parameters:
bytes
- the binary data to send
-
send
abstract void send(Array<byte> bytes)
Send Binary data (plain bytes) to the other end.
- Parameters:
bytes
- the byte array to send
-
sendFrame
abstract void sendFrame(Framedata framedata)
Send a frame to the other end
- Parameters:
framedata
- the frame to send to the other end
-
sendFrame
abstract void sendFrame(Collection<Framedata> frames)
Send a collection of frames to the other end
- Parameters:
frames
- the frames to send to the other end
-
sendPing
abstract void sendPing()
Send a ping to the other end
-
sendFragmentedFrame
abstract void sendFragmentedFrame(Opcode op, ByteBuffer buffer, boolean fin)
Allows to send continuous/fragmented frames conveniently. For more into on this frame typesee http://tools.ietf.org/html/rfc6455#section-5.4
If the first frame you send is also the last then it is not a fragmented frame and willreceived via onMessage instead of onFragmented even though it was send by this method.
- Parameters:
op
- This is only important for the first frame in the sequence.buffer
- The buffer which contains the payload.fin
- true means the current frame is the last in the sequence.
-
hasBufferedData
abstract boolean hasBufferedData()
Checks if the websocket has buffered data
-
getRemoteSocketAddress
abstract InetSocketAddress getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or
{@code null}
if it isunconnected.
-
getLocalSocketAddress
abstract InetSocketAddress getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to.
-
isOpen
abstract boolean isOpen()
Is the websocket in the state OPEN
-
isClosing
abstract boolean isClosing()
Is the websocket in the state CLOSING
-
isFlushAndClose
abstract boolean isFlushAndClose()
Returns true when no further frames may be submitted This happens before the socketconnection is closed.
-
isClosed
abstract boolean isClosed()
Is the websocket in the state CLOSED
-
getReadyState
abstract ReadyState getReadyState()
Retrieve the WebSocket 'ReadyState'. This represents the state of the connection. It returns anumerical value, as per W3C WebSockets specs.
-
getResourceDescriptor
abstract String getResourceDescriptor()
Returns the HTTP Request-URI as defined by http://tools.ietf.org/html/rfc2616#section-5.1.2If the opening handshake has not yet happened it will return null.
-
setAttachment
abstract <T> void setAttachment(T attachment)
Setter for an attachment on the socket connection. The attachment may be of any type.
- Parameters:
attachment
- The object to be attached to the user
-
getAttachment
abstract <T> T getAttachment()
Getter for the connection attachment.
-
hasSSLSupport
abstract boolean hasSSLSupport()
Does this websocket use an encrypted (wss/ssl) or unencrypted (ws) connection
-
getSSLSession
abstract SSLSession getSSLSession()
Returns the ssl session of websocket, if ssl/wss is used for this instance.
-
getProtocol
abstract IProtocol getProtocol()
Returns the used Sec-WebSocket-Protocol for this websocket connection
-
-
-
-