Package org.xnio.conduits
Class FramingMessageSourceConduit
java.lang.Object
org.xnio.conduits.AbstractConduit<StreamSourceConduit>
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 TypeMethodDescriptionvoid
Block until this channel becomes readable again.void
awaitReadable
(long time, TimeUnit timeUnit) Block until this conduit becomes readable again, or until the timeout expires.int
receive
(ByteBuffer dst) Receive a message.long
receive
(ByteBuffer[] dsts, int offs, int len) Receive a message.void
Indicate that the conduit'sReadReadyHandler
should be invoked as soon as data can be read without blocking.void
Indicate that no more data will be read from this conduit.Methods inherited from class org.xnio.conduits.AbstractSourceConduit
getReadThread, isReadResumed, isReadShutdown, setReadReadyHandler, suspendReads, wakeupReads
Methods inherited from class org.xnio.conduits.AbstractConduit
getWorker
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:SourceConduit
Indicate that the conduit'sReadReadyHandler
should be invoked as soon as data can be read without blocking.- Specified by:
resumeReads
in interfaceSourceConduit
- Overrides:
resumeReads
in classAbstractSourceConduit<StreamSourceConduit>
-
awaitReadable
Description copied from interface:SourceConduit
Block 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:
awaitReadable
in interfaceSourceConduit
- Overrides:
awaitReadable
in classAbstractSourceConduit<StreamSourceConduit>
- Parameters:
time
- the time to waittimeUnit
- the time unit- Throws:
IOException
- if an I/O error occurs
-
awaitReadable
Description copied from interface:SourceConduit
Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadable
in interfaceSourceConduit
- Overrides:
awaitReadable
in classAbstractSourceConduit<StreamSourceConduit>
- Throws:
IOException
- if an I/O error occurs
-
terminateReads
Description copied from interface:SourceConduit
Indicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.- Specified by:
terminateReads
in interfaceSourceConduit
- Overrides:
terminateReads
in classAbstractSourceConduit<StreamSourceConduit>
- Throws:
IOException
- if there was a problem
-
receive
Description copied from interface:MessageSourceConduit
Receive a message.- Specified by:
receive
in 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:MessageSourceConduit
Receive a message.- Specified by:
receive
in interfaceMessageSourceConduit
- Parameters:
offs
- 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
-