Top Description Fields Constructors Methods
org.xnio.conduits

public final Class FramingMessageSinkConduit

extends AbstractSinkConduit<StreamSinkConduit>
implements MessageSinkConduit
Class Inheritance
All Implemented Interfaces
org.xnio.conduits.MessageSinkConduit, org.xnio.conduits.SinkConduit, org.xnio.conduits.Conduit
Static Imports
org.xnio._private.Messages.msg

A message sink conduit which implements a simple message framing protocol over a stream conduit.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private final boolean
private final Pooled<ByteBuffer>
transmitBuffer

References Deprecated Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
public
FramingMessageSinkConduit(final StreamSinkConduit
the delegate conduit to set
next
,
final boolean
true to use 4-byte lengths, false to use 2-byte lengths
longLengths
,
final Pooled<ByteBuffer>
the transmit buffer to use
transmitBuffer
)
References Deprecated Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
flush()

Overrides org.xnio.conduits.AbstractSinkConduit.flush.

Implements org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

public boolean
send(final ByteBuffer
the message to send
src
)

Implements org.xnio.conduits.MessageSinkConduit.send.

Send a complete message.

public boolean
send(final ByteBuffer[]
the buffers holding the message to send
srcs
,
final int
the offset into the buffer array of the first buffer
offs
,
final int
the number of buffers that contain data to send
len
)

Implements org.xnio.conduits.MessageSinkConduit.send.

Send a complete message.

public boolean
sendFinal(ByteBuffer
the message to send
src
)

Implements org.xnio.conduits.MessageSinkConduit.sendFinal.

Send a complete message.

public boolean
sendFinal(ByteBuffer[]
the buffers holding the message to send
srcs
,
int
the offset into the buffer array of the first buffer
offs
,
int
the number of buffers that contain data to send
len
)

Implements org.xnio.conduits.MessageSinkConduit.sendFinal.

Send a complete message.

public void
public void
truncateWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.truncateWrites.

Implements org.xnio.conduits.SinkConduit.truncateWrites.

Terminate writes and discard any outstanding write data.

private boolean
Inherited from org.xnio.conduits.AbstractSinkConduit:
awaitWritableawaitWritablegetWriteThreadisWriteResumedisWriteShutdownresumeWritessetWriteReadyHandlersuspendWriteswakeupWrites

Field Detail

longLengthsback to summary
private final boolean longLengths
transmitBufferback to summary
private final Pooled<ByteBuffer> transmitBuffer

References Deprecated

Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Constructor Detail

FramingMessageSinkConduitback to summary
public FramingMessageSinkConduit(final StreamSinkConduit next, final boolean longLengths, final Pooled<ByteBuffer> transmitBuffer)

References Deprecated

Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Construct a new instance.

Parameters
next:StreamSinkConduit

the delegate conduit to set

longLengths:boolean

true to use 4-byte lengths, false to use 2-byte lengths

transmitBuffer:Pooled<ByteBuffer>

the transmit buffer to use

Method Detail

flushback to summary
public boolean flush() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.flush.

Implements org.xnio.conduits.SinkConduit.flush.

Doc from org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

Returns:boolean

true if everything is flushed, false otherwise

Exceptions
IOException:
if flush fails
sendback to summary
public boolean send(final ByteBuffer src) throws IOException

Implements org.xnio.conduits.MessageSinkConduit.send.

Doc from org.xnio.conduits.MessageSinkConduit.send.

Send a complete message.

Parameters
src:ByteBuffer

the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendback to summary
public boolean send(final ByteBuffer[] srcs, final int offs, final int len) throws IOException

Implements org.xnio.conduits.MessageSinkConduit.send.

Doc from org.xnio.conduits.MessageSinkConduit.send.

Send a complete message.

Parameters
srcs:ByteBuffer[]

the buffers holding the message to send

offs:int

the offset into the buffer array of the first buffer

len:int

the number of buffers that contain data to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer src) throws IOException

Implements org.xnio.conduits.MessageSinkConduit.sendFinal.

Doc from org.xnio.conduits.MessageSinkConduit.sendFinal.

Send a complete message. If the message is successfully sent then the sink will have its writes terminated.

Parameters
src:ByteBuffer

the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer[] srcs, int offs, int len) throws IOException

Implements org.xnio.conduits.MessageSinkConduit.sendFinal.

Doc from org.xnio.conduits.MessageSinkConduit.sendFinal.

Send a complete message. If the message is successfully sent then the sink will have its writes terminated.

Parameters
srcs:ByteBuffer[]

the buffers holding the message to send

offs:int

the offset into the buffer array of the first buffer

len:int

the number of buffers that contain data to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
terminateWritesback to summary
public void terminateWrites() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.terminateWrites.

Implements org.xnio.conduits.SinkConduit.terminateWrites.

Doc from org.xnio.conduits.SinkConduit.terminateWrites.

Signal that no more write data is forthcoming. The conduit must be flush()ed before it is considered to be shut down.

truncateWritesback to summary
public void truncateWrites() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.truncateWrites.

Implements org.xnio.conduits.SinkConduit.truncateWrites.

Doc from org.xnio.conduits.SinkConduit.truncateWrites.

Terminate writes and discard any outstanding write data. The conduit is terminated and flushed regardless of the outcome of this method.

Exceptions
IOException:
if channel termination failed for some reason
writeBufferback to summary
private boolean writeBuffer() throws IOException