public abstract class WebSocketChannel extends AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
ConnectedChannel
which can be used to send and receive WebSocket Frames.Modifier and Type | Class and Description |
---|---|
static interface | WebSocketChannel.PartialFrame Interface that represents a frame channel that is in the process of being created |
Modifier and Type | Field and Description |
---|---|
protected ExtensionFunction | extensionFunction |
protected boolean | extensionsSupported |
protected StreamSourceFrameChannel | fragmentedChannel |
protected boolean | hasReservedOpCode |
Modifier | Constructor and Description |
---|---|
protected | WebSocketChannel(org.xnio.StreamConnection connectedStreamChannel, ByteBufferPool bufferPool, WebSocketVersion version, String wsUrl, String subProtocol, boolean client, boolean extensionsSupported, ExtensionFunction extensionFunction, Set<WebSocketChannel> peerConnections, org.xnio.OptionMap options) Create a new WebSocketChannel 8 |
Modifier and Type | Method and Description |
---|---|
boolean | areExtensionsSupported() Returns true if extensions are supported by this WebSocket Channel. |
protected StreamSourceFrameChannel | createChannel(FrameHeaderData frameHeaderData, PooledByteBuffer frameData) Method that creates the actual stream source channel implementation that is in use. |
protected IdleTimeoutConduit | createIdleTimeoutChannel(org.xnio.StreamConnection connectedStreamChannel) |
protected abstract StreamSinkFrameChannel | createStreamSinkChannel(WebSocketFrameType type) Create a new StreamSinkFrameChannel which can be used to send a WebSocket Frame of the type WebSocketFrameType . |
Object | getAttribute(String key) |
int | getCloseCode() |
String | getCloseReason() |
InetSocketAddress | getDestinationAddress() Get the destination address of the WebSocket Channel. |
ExtensionFunction | getExtensionFunction() |
protected WebSocketFramePriority | getFramePriority() |
Set<WebSocketChannel> | getPeerConnections() Returns all 'peer' web socket connections that were created from the same endpoint. |
protected Collection<AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>> | getReceivers() |
String | getRequestScheme() Get the request URI scheme. |
InetSocketAddress | getSourceAddress() Get the source address of the WebSocket Channel. |
String | getSubProtocol() |
Set<String> | getSubProtocols() Deprecated. |
String | getUrl() Return the URL of the WebSocket endpoint. |
WebSocketVersion | getVersion() Return the WebSocketVersion which is used |
protected void | handleBrokenSinkChannel(Throwable e) Method that is invoked when then write side of a channel is broken. |
protected void | handleBrokenSourceChannel(Throwable e) Method that is invoked when the read side of the channel is broken. |
boolean | isClient() |
boolean | isCloseFrameReceived() |
boolean | isCloseFrameSent() |
boolean | isCloseInitiatedByRemotePeer() If this is true the session is being closed because the remote peer sent a close frame |
protected boolean | isLastFrameReceived() Returns true if the protocol specific final frame has been received. |
protected boolean | isLastFrameSent() |
protected boolean | isReadsBroken() |
boolean | isSecure() Return true if this is handled via WebSocket Secure. |
protected void | lastDataRead() Method than is invoked when read() returns -1. |
protected void | markReadsBroken(Throwable cause) Called when a source sub channel fails to fulfil its contract, and leaves the channel in an inconsistent state. |
protected FrameHeaderData | parseFrame(ByteBuffer data) Attempts to parse an incoming frame header from the data in the buffer. |
protected abstract WebSocketChannel.PartialFrame | receiveFrame() Create a new StreamSourceFrameChannel which can be used to read the data of the received Frame |
StreamSinkFrameChannel | send(WebSocketFrameType type) Returns a new StreamSinkFrameChannel for sending the given WebSocketFrameType with the given payload. |
void | sendClose() Send a Close frame without a payload |
boolean | setAttribute(String key, Object value) |
void | setCloseCode(int closeCode) |
void | setCloseReason(String closeReason) |
addCloseTask, close, closeSubChannels, flush, flushSenders, getBufferPool, getCloseSetter, getIdleTimeout, getIoThread, getLocalAddress, getLocalAddress, getOption, getPeerAddress, getPeerAddress, getReceiveSetter, getSettings, getUnderlyingConnection, getWorker, isOpen, isReceivesResumed, isRequireExplicitFlush, isWritesBroken, markWritesBroken, queueFrame, recalculateHeldFrames, receive, resumeReceives, setIdleTimeout, setOption, setRequireExplicitFlush, supportsOption, suspendReceives, toString, writeExceptionHandler
protected final boolean extensionsSupported
protected final ExtensionFunction extensionFunction
protected final boolean hasReservedOpCode
protected StreamSourceFrameChannel fragmentedChannel
protected WebSocketChannel(org.xnio.StreamConnection connectedStreamChannel, ByteBufferPool bufferPool, WebSocketVersion version, String wsUrl, String subProtocol, boolean client, boolean extensionsSupported, ExtensionFunction extensionFunction, Set<WebSocketChannel> peerConnections, org.xnio.OptionMap options)
WebSocketChannel
8connectedStreamChannel
- The ConnectedStreamChannel
over which the WebSocket Frames should get send and received. Be aware that it already must be "upgraded".bufferPool
- The Pool
which will be used to acquire ByteBuffer
's from.version
- The WebSocketVersion
of the WebSocketChannel
wsUrl
- The url for which the channel was created.client
- peerConnections
- The concurrent set that is used to track open connections associtated with an endpointprotected Collection<AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>> getReceivers()
getReceivers
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
protected IdleTimeoutConduit createIdleTimeoutChannel(org.xnio.StreamConnection connectedStreamChannel)
protected boolean isLastFrameSent()
isLastFrameSent
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
true
If the last frame has been sentprotected boolean isLastFrameReceived()
AbstractFramedChannel
isLastFrameReceived
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
true
If the last frame has been receivedprotected void markReadsBroken(Throwable cause)
AbstractFramedChannel
The underlying read side will be forcibly closed.
markReadsBroken
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
cause
- The possibly null causeprotected void lastDataRead()
AbstractFramedChannel
lastDataRead
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
protected boolean isReadsBroken()
isReadsBroken
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
protected FrameHeaderData parseFrame(ByteBuffer data) throws IOException
AbstractFramedChannel
parseFrame
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
data
- The data that has been read from the channelnull
if the data was incompleteIOException
- If the data could not be parsed.protected abstract WebSocketChannel.PartialFrame receiveFrame()
StreamSourceFrameChannel
which can be used to read the data of the received FrameStreamSourceFrameChannel
will be used to read a Frame from. This will return null
if the right StreamSourceFrameChannel
could not be detected with the given buffer and so more data is needed.protected StreamSourceFrameChannel createChannel(FrameHeaderData frameHeaderData, PooledByteBuffer frameData)
AbstractFramedChannel
createChannel
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
frameHeaderData
- The header data, as returned by AbstractFramedChannel.parseFrame(java.nio.ByteBuffer)
frameData
- Any additional data for the frame that has already been read. This may not be the complete frame contentspublic boolean areExtensionsSupported()
true
if extensions are supported by this WebSocket Channel.protected void handleBrokenSourceChannel(Throwable e)
AbstractFramedChannel
handleBrokenSourceChannel
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
protected void handleBrokenSinkChannel(Throwable e)
AbstractFramedChannel
handleBrokenSinkChannel
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
@Deprecated public Set<String> getSubProtocols()
Set
of the selected subprotocols if any.public String getSubProtocol()
public boolean isCloseFrameReceived()
public boolean isCloseFrameSent()
public String getRequestScheme()
ws
or wss
.public boolean isSecure()
true
if this is handled via WebSocket Secure.public String getUrl()
public WebSocketVersion getVersion()
WebSocketVersion
which is usedWebSocketVersion
which is in usepublic InetSocketAddress getSourceAddress()
getSourceAddress
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
public InetSocketAddress getDestinationAddress()
getDestinationAddress
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
public boolean isClient()
public final StreamSinkFrameChannel send(WebSocketFrameType type) throws IOException
StreamSinkFrameChannel
for sending the given WebSocketFrameType
with the given payload. If this method is called multiple times, subsequent StreamSinkFrameChannel
's will not be writable until all previous frames were completely written.type
- The WebSocketFrameType
for which a StreamSinkChannel
should be createdIOException
public void sendClose() throws IOException
IOException
protected abstract StreamSinkFrameChannel createStreamSinkChannel(WebSocketFrameType type)
WebSocketFrameType
.type
- The WebSocketFrameType
of the WebSocketFrame which will be send over this StreamSinkFrameChannel
protected WebSocketFramePriority getFramePriority()
getFramePriority
in class AbstractFramedChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
public Set<WebSocketChannel> getPeerConnections()
public boolean isCloseInitiatedByRemotePeer()
true
if the remote peer closed the connectionpublic String getCloseReason()
public void setCloseReason(String closeReason)
public int getCloseCode()
public void setCloseCode(int closeCode)
public ExtensionFunction getExtensionFunction()
Copyright © 2020 JBoss by Red Hat. All rights reserved.