|
XNIO API 3.0.4.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xnio.channels.TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
org.xnio.channels.FramedMessageChannel
public class FramedMessageChannel

A connected message channel providing a SASL-style framing layer over a stream channel where each message is prepended by a four-byte length field.
| Field Summary |
|---|
| Fields inherited from class org.xnio.channels.TranslatingSuspendableChannel |
|---|
channel |
| Constructor Summary | |
|---|---|
FramedMessageChannel(ConnectedStreamChannel channel,
ByteBuffer receiveBuffer,
ByteBuffer transmitBuffer)
Construct a new instance. |
|
FramedMessageChannel(ConnectedStreamChannel channel,
Pooled<ByteBuffer> receiveBuffer,
Pooled<ByteBuffer> transmitBuffer)
Construct a new instance. |
|
| Method Summary | ||
|---|---|---|
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. |
|
|
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. |
|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.xnio.channels.ConnectedMessageChannel |
|---|
getCloseSetter, getReadSetter, getWriteSetter |
| Methods inherited from interface org.xnio.channels.SuspendableReadChannel |
|---|
awaitReadable, awaitReadable, getReadThread, isReadResumed, resumeReads, shutdownReads, suspendReads, wakeupReads |
| Methods inherited from interface org.xnio.channels.SuspendableWriteChannel |
|---|
awaitWritable, awaitWritable, close, flush, getWriteThread, isWriteResumed, resumeWrites, shutdownWrites, suspendWrites, wakeupWrites |
| Methods inherited from interface org.xnio.channels.CloseableChannel |
|---|
getWorker |
| Methods inherited from interface java.nio.channels.Channel |
|---|
isOpen |
| Methods inherited from interface org.xnio.channels.Configurable |
|---|
getOption, setOption, supportsOption |
| Constructor Detail |
|---|
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)| Method Detail |
|---|
public int receive(ByteBuffer buffer)
throws IOException
receive in interface ReadableMessageChannelbuffer - the buffer that will hold the message
IOException - if an I/O error occurs
public long receive(ByteBuffer[] buffers)
throws IOException
receive in interface ReadableMessageChannelbuffers - the buffers that will hold the message
IOException - if an I/O error occurs
public long receive(ByteBuffer[] buffers,
int offs,
int len)
throws IOException
receive in interface ReadableMessageChannelbuffers - 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 fill
IOException - if an I/O error occurs
protected void shutdownReadsAction(boolean writeComplete)
throws IOException
TranslatingSuspendableChannel
shutdownReadsAction in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>IOException - if an error occurs
public boolean send(ByteBuffer buffer)
throws IOException
send in interface WritableMessageChannelbuffer - the message to send
true if the message was sent, or false if it would block
IOException - if an I/O error occurs
public boolean send(ByteBuffer[] buffers)
throws IOException
send in interface WritableMessageChannelbuffers - the buffers holding the message to send
true if the message was sent, or false if it would block
IOException - if an I/O error occurs
public boolean send(ByteBuffer[] buffers,
int offs,
int len)
throws IOException
send in interface WritableMessageChannelbuffers - 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 send
true if the message was sent, or false if it would block
IOException - if an I/O error occurs
protected boolean flushAction(boolean shutDown)
throws IOException
TranslatingSuspendableChannelshutDown 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 otherwise
true if the flush succeeded, false if it would block
IOException - if an error occurs
protected void shutdownWritesComplete(boolean readShutDown)
throws IOException
TranslatingSuspendableChannel
shutdownWritesComplete in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>readShutDown - true if the read side was already shut down, false otherwise
IOException - if an error occurs
protected void closeAction(boolean readShutDown,
boolean writeShutDown)
throws IOException
TranslatingSuspendableChannelTranslatingSuspendableChannel.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 down
IOException - if an error occurspublic SocketAddress getPeerAddress()
getPeerAddress in interface ConnectedChannelpublic <A extends SocketAddress> A getPeerAddress(Class<A> type)
null if the address is not of that
type.
getPeerAddress in interface ConnectedChanneltype - the address type class
null if unknownpublic SocketAddress getLocalAddress()
getLocalAddress in interface BoundChannelpublic <A extends SocketAddress> A getLocalAddress(Class<A> type)
null if the address is not of that
type.
getLocalAddress in interface BoundChannelA - the address typetype - the address type class
null if unknownpublic ConnectedStreamChannel getChannel()
getChannel in interface WrappedChannel<ConnectedStreamChannel>getChannel in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
|
XNIO API 3.0.4.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||