public abstract class StreamSourceFrameChannel extends AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
Modifier and Type | Field and Description |
---|---|
protected WebSocketFrameType |
type |
EMPTY
Modifier | Constructor and Description |
---|---|
protected |
StreamSourceFrameChannel(WebSocketChannel wsChannel,
WebSocketFrameType type,
int rsv,
boolean finalFragment,
PooledByteBuffer pooled,
long frameLength,
Masker masker,
ChannelFunction... functions) |
protected |
StreamSourceFrameChannel(WebSocketChannel wsChannel,
WebSocketFrameType type,
PooledByteBuffer pooled,
long frameLength) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterRead(ByteBuffer buffer,
int position,
int length)
Called after data was read into the
ByteBuffer |
protected void |
checker(ByteBuffer buffer,
int position,
int length,
boolean complete) |
void |
finalFrame() |
protected WebSocketChannel |
getFramedChannel() |
int |
getRsv()
Return the rsv which is used for extensions.
|
WebSocketFrameType |
getType()
Return the
WebSocketFrameType or null if its not known at the calling time. |
WebSocketChannel |
getWebSocketChannel() |
protected void |
handleHeaderData(FrameHeaderData headerData) |
boolean |
isFinalFragment()
Flag to indicate if this frame is the final fragment in a message.
|
protected PooledByteBuffer |
processFrameData(PooledByteBuffer frameData,
boolean lastFragmentOfFrame) |
int |
read(ByteBuffer dst) |
long |
read(ByteBuffer[] dsts) |
long |
read(ByteBuffer[] dsts,
int offset,
int length) |
long |
transferTo(long count,
ByteBuffer throughBuffer,
StreamSinkChannel target)
Transfers bytes into the given channel target.
|
long |
transferTo(long position,
long count,
FileChannel target)
Transfers bytes into the given file from this channel.
|
addCloseTask, awaitReadable, awaitReadable, channelForciblyClosed, close, complete, dataReady, getCloseSetter, getIoThread, getMaxStreamSize, getOption, getReadFrameCount, getReadSetter, getReadThread, getWorker, isComplete, isLastFrame, isOpen, isReadResumed, lastFrame, markStreamBroken, resumeReads, setMaxStreamSize, setOption, shutdownReads, supportsOption, suspendReads, updateFrameDataRemaining, wakeupReads
protected final WebSocketFrameType type
protected StreamSourceFrameChannel(WebSocketChannel wsChannel, WebSocketFrameType type, PooledByteBuffer pooled, long frameLength)
protected StreamSourceFrameChannel(WebSocketChannel wsChannel, WebSocketFrameType type, int rsv, boolean finalFragment, PooledByteBuffer pooled, long frameLength, Masker masker, ChannelFunction... functions)
public WebSocketFrameType getType()
WebSocketFrameType
or null
if its not known at the calling time.public boolean isFinalFragment()
public int getRsv()
protected WebSocketChannel getFramedChannel()
public WebSocketChannel getWebSocketChannel()
public void finalFrame()
protected void handleHeaderData(FrameHeaderData headerData)
public final long transferTo(long position, long count, FileChannel target) throws IOException
StreamSourceChannel
FileChannel.transferFrom(ReadableByteChannel, long, long)
may provide a performance advantage on some platforms.
If the current thread is interrupted when this method is called, it may throw a InterruptedIOException
;
however, if this exception is thrown, the InterruptedIOException.bytesTransferred
field is
guaranteed to be 0.
transferTo
in interface StreamSourceChannel
transferTo
in class AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
position
- the position within the file from which the transfer is to begincount
- the number of bytes to be transferredtarget
- the file to write toIOException
- if an I/O error occurspublic final long transferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) throws IOException
StreamSourceChannel
throughBuffer
parameter's buffer
space. On entry, throughBuffer
will be cleared. On exit, the buffer will be
flipped for emptying, and may possibly be empty or may contain data. If this method returns a value less than
count
, then the remaining data in throughBuffer
may contain data read from this channel which must
be written to target
to complete the operation. Note that using a direct buffer may provide an
intermediate performance gain on platforms without zero-copy facilities.
If the current thread is interrupted when this method is called, it may throw a InterruptedIOException
;
however, if this exception is thrown, the InterruptedIOException.bytesTransferred
field is
guaranteed to be 0.
Note that the return value is the amount of data that was actually transferred to the StreamSinkChannel
.
The actual amount of data read could be larger than this, and can be calculated by adding the return value and
the amount of data left in throughBuffer
.
transferTo
in interface StreamSourceChannel
transferTo
in class AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
count
- the number of bytes to be transferredthroughBuffer
- the buffer to copy through.target
- the destination to write toIOException
- if an I/O error occurspublic int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in class AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
IOException
public final long read(ByteBuffer[] dsts) throws IOException
read
in interface ScatteringByteChannel
read
in class AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
IOException
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read
in interface ScatteringByteChannel
read
in class AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
IOException
protected void afterRead(ByteBuffer buffer, int position, int length) throws IOException
ByteBuffer
buffer
- the ByteBuffer
into which the data was readposition
- the position it was written tolength
- the number of bytes there were writtenIOException
- thrown if an error occursprotected void checker(ByteBuffer buffer, int position, int length, boolean complete) throws IOException
IOException
protected PooledByteBuffer processFrameData(PooledByteBuffer frameData, boolean lastFragmentOfFrame) throws IOException
processFrameData
in class AbstractFramedStreamSourceChannel<WebSocketChannel,StreamSourceFrameChannel,StreamSinkFrameChannel>
IOException
Copyright © 2017 JBoss by Red Hat. All rights reserved.