Package org.xnio.conduits
Class FramingMessageSourceConduit
java.lang.Object
org.xnio.conduits.AbstractConduit<D>
org.xnio.conduits.AbstractSourceConduit<StreamSourceConduit>
org.xnio.conduits.FramingMessageSourceConduit
- All Implemented Interfaces:
Conduit,MessageSourceConduit,SourceConduit
public final class FramingMessageSourceConduit
extends AbstractSourceConduit<StreamSourceConduit>
implements MessageSourceConduit
A message source conduit which implements a simple message framing protocol over a stream conduit.
- Author:
- David M. Lloyd
-
Field Summary
Fields inherited from class org.xnio.conduits.AbstractConduit
next -
Constructor Summary
ConstructorsConstructorDescriptionFramingMessageSourceConduit(StreamSourceConduit next, Pooled<ByteBuffer> receiveBuffer) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidBlock until this channel becomes readable again.voidawaitReadable(long time, TimeUnit timeUnit) Block until this conduit becomes readable again, or until the timeout expires.intreceive(ByteBuffer dst) Receive a message.longreceive(ByteBuffer[] dsts, int offs, int len) Receive a message.voidIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.voidIndicate that no more data will be read from this conduit.Methods inherited from class org.xnio.conduits.AbstractSourceConduit
getReadThread, isReadResumed, isReadShutdown, setReadReadyHandler, suspendReads, wakeupReadsMethods inherited from class org.xnio.conduits.AbstractConduit
getWorkerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xnio.conduits.SourceConduit
getReadThread, isReadResumed, isReadShutdown, setReadReadyHandler, suspendReads, wakeupReads
-
Constructor Details
-
FramingMessageSourceConduit
Construct a new instance.- Parameters:
next- the delegate conduit to setreceiveBuffer- the transmit buffer to use
-
-
Method Details
-
resumeReads
public void resumeReads()Description copied from interface:SourceConduitIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.- Specified by:
resumeReadsin interfaceSourceConduit- Overrides:
resumeReadsin classAbstractSourceConduit<StreamSourceConduit>
-
awaitReadable
Description copied from interface:SourceConduitBlock until this conduit becomes readable again, or until the timeout expires. This method may return spuriously before the conduit becomes readable or the timeout expires.- Specified by:
awaitReadablein interfaceSourceConduit- Overrides:
awaitReadablein classAbstractSourceConduit<StreamSourceConduit>- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as wellIOException- if an I/O error occurs
-
awaitReadable
Description copied from interface:SourceConduitBlock until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadablein interfaceSourceConduit- Overrides:
awaitReadablein classAbstractSourceConduit<StreamSourceConduit>- Throws:
InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as wellIOException- if an I/O error occurs
-
terminateReads
Description copied from interface:SourceConduitIndicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.- Specified by:
terminateReadsin interfaceSourceConduit- Overrides:
terminateReadsin classAbstractSourceConduit<StreamSourceConduit>- Throws:
IOException- if there was a problem
-
receive
Description copied from interface:MessageSourceConduitReceive a message.- Specified by:
receivein interfaceMessageSourceConduit- Returns:
- the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
- Throws:
IOException- if an I/O error occurs
-
receive
Description copied from interface:MessageSourceConduitReceive a message.- Specified by:
receivein interfaceMessageSourceConduitoffs- the offset into the array of buffers of the first buffer to read intolen- the number of buffers to fill- Returns:
- the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
- Throws:
IOException- if an I/O error occurs
-