public class FramedMessageChannel extends TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel> implements ConnectedMessageChannel
channel
Constructor and Description |
---|
FramedMessageChannel(ConnectedStreamChannel channel,
ByteBuffer receiveBuffer,
ByteBuffer transmitBuffer)
Construct a new instance.
|
FramedMessageChannel(ConnectedStreamChannel channel,
Pooled<ByteBuffer> receiveBuffer,
Pooled<ByteBuffer> transmitBuffer)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeAction(boolean readShutDown,
boolean writeShutDown)
The action to perform when the channel is closed via the
TranslatingSuspendableChannel.close() method. |
protected boolean |
flushAction(boolean shutDown)
The action to perform when the channel is flushed.
|
ConnectedStreamChannel |
getChannel()
Get the underlying channel.
|
SocketAddress |
getLocalAddress()
Get the local address that this channel is bound to.
|
<A extends SocketAddress> |
getLocalAddress(Class<A> type)
Get the local address of a given type, or
null if the address is not of that
type. |
SocketAddress |
getPeerAddress()
Get the peer address of this channel.
|
<A extends SocketAddress> |
getPeerAddress(Class<A> type)
Get the peer address of a given type, or
null if the address is not of that
type. |
int |
receive(ByteBuffer buffer)
Receive a message.
|
long |
receive(ByteBuffer[] buffers)
Receive a message.
|
long |
receive(ByteBuffer[] buffers,
int offs,
int len)
Receive a message.
|
boolean |
send(ByteBuffer buffer)
Send a complete message.
|
boolean |
send(ByteBuffer[] buffers)
Send a complete message.
|
boolean |
send(ByteBuffer[] buffers,
int offs,
int len)
Send a complete message.
|
protected void |
shutdownReadsAction(boolean writeComplete)
The action to perform when reads are shut down.
|
protected void |
shutdownWritesComplete(boolean readShutDown)
Notification that the channel has successfully flushed after having shut down writes.
|
awaitReadable, awaitReadable, awaitWritable, awaitWritable, clearReadReady, clearReadRequiresWrite, clearWriteReady, clearWriteRequiresRead, close, flush, getCloseSetter, getOption, getReadSetter, getReadThread, getWorker, getWriteSetter, getWriteThread, handleClosed, handleReadable, handleWritable, isOpen, isReadResumed, isReadShutDown, isWriteComplete, isWriteResumed, isWriteShutDown, readRequiresWrite, removeReadRequiresExternal, removeWriteRequiresExternal, resumeReads, resumeWrites, setClosed, setOption, setReadReady, setReadRequiresWrite, setReadShutDown, setWriteReady, setWriteRequiresRead, setWriteShutDown, shutdownReads, shutdownWrites, shutdownWritesAction, supportsOption, suspendReads, suspendWrites, thisTyped, toString, tryAddReadRequiresExternal, tryAddWriteRequiresExternal, wakeupReads, wakeupWrites, writeRequiresRead
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCloseSetter, getReadSetter, getWriteSetter
awaitReadable, awaitReadable, getReadThread, isReadResumed, resumeReads, shutdownReads, suspendReads, wakeupReads
awaitWritable, awaitWritable, close, flush, getWriteThread, isWriteResumed, resumeWrites, shutdownWrites, suspendWrites, wakeupWrites
getWorker
getOption, setOption, supportsOption
public FramedMessageChannel(ConnectedStreamChannel channel, ByteBuffer receiveBuffer, ByteBuffer transmitBuffer)
channel
- the channel to wrapreceiveBuffer
- the receive buffer (should be direct)transmitBuffer
- the send buffer (should be direct)public FramedMessageChannel(ConnectedStreamChannel channel, Pooled<ByteBuffer> receiveBuffer, Pooled<ByteBuffer> transmitBuffer)
channel
- the channel to wrapreceiveBuffer
- the receive buffer (should be direct)transmitBuffer
- the send buffer (should be direct)public int receive(ByteBuffer buffer) throws IOException
receive
in interface ReadableMessageChannel
buffer
- the buffer that will hold the messageIOException
- if an I/O error occurspublic long receive(ByteBuffer[] buffers) throws IOException
receive
in interface ReadableMessageChannel
buffers
- the buffers that will hold the messageIOException
- if an I/O error occurspublic long receive(ByteBuffer[] buffers, int offs, int len) throws IOException
receive
in interface ReadableMessageChannel
buffers
- the buffers that will hold the messageoffs
- the offset into the array of buffers of the first buffer to read intolen
- the number of buffers to fillIOException
- if an I/O error occursprotected void shutdownReadsAction(boolean writeComplete) throws IOException
TranslatingSuspendableChannel
shutdownReadsAction
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
IOException
- if an error occurspublic boolean send(ByteBuffer buffer) throws IOException
send
in interface WritableMessageChannel
buffer
- the message to sendtrue
if the message was sent, or false
if it would blockIOException
- if an I/O error occurspublic boolean send(ByteBuffer[] buffers) throws IOException
send
in interface WritableMessageChannel
buffers
- the buffers holding the message to sendtrue
if the message was sent, or false
if it would blockIOException
- if an I/O error occurspublic boolean send(ByteBuffer[] buffers, int offs, int len) throws IOException
send
in interface WritableMessageChannel
buffers
- the buffers holding the message to sendoffs
- the offset into the buffer array of the first bufferlen
- the number of buffers that contain data to sendtrue
if the message was sent, or false
if it would blockIOException
- if an I/O error occursprotected boolean flushAction(boolean shutDown) throws IOException
TranslatingSuspendableChannel
shutDown
parameter is set, and this method returns true
, the underlying channel will be
shut down and this method will never be called again (future calls to TranslatingSuspendableChannel.flush()
will flush the underlying
channel until it returns true
).flushAction
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
shutDown
- true
if the channel's write side has been shut down, false
otherwisetrue
if the flush succeeded, false
if it would blockIOException
- if an error occursprotected void shutdownWritesComplete(boolean readShutDown) throws IOException
TranslatingSuspendableChannel
shutdownWritesComplete
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
readShutDown
- true
if the read side was already shut down, false
otherwiseIOException
- if an error occursprotected void closeAction(boolean readShutDown, boolean writeShutDown) throws IOException
TranslatingSuspendableChannel
TranslatingSuspendableChannel.close()
method. By default, the underlying
channel is closed.closeAction
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
readShutDown
- if reads were previously shut downwriteShutDown
- if writes were previously shut downIOException
- if an error occurspublic SocketAddress getPeerAddress()
getPeerAddress
in interface ConnectedChannel
public <A extends SocketAddress> A getPeerAddress(Class<A> type)
null
if the address is not of that
type.getPeerAddress
in interface ConnectedChannel
type
- the address type classnull
if unknownpublic SocketAddress getLocalAddress()
getLocalAddress
in interface BoundChannel
public <A extends SocketAddress> A getLocalAddress(Class<A> type)
null
if the address is not of that
type.getLocalAddress
in interface BoundChannel
A
- the address typetype
- the address type classnull
if unknownpublic ConnectedStreamChannel getChannel()
getChannel
in interface WrappedChannel<ConnectedStreamChannel>
getChannel
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
Copyright © 2018 JBoss by Red Hat. All rights reserved.