- All Superinterfaces:
org.refcodes.io.Availability
,org.refcodes.component.Closable
,org.refcodes.component.Closable.CloseAutomaton
,org.refcodes.component.ClosedAccessor
,org.refcodes.component.ConnectableComponent
,org.refcodes.component.ConnectableComponent.ConnectableAutomaton
,org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.component.OpenedAccessor
,org.refcodes.io.Receivable
,SegmentDestination
- All Known Subinterfaces:
Port<PM>
,SegmentTransceiver
,SerialReceiver
,SerialTransceiver
- All Known Implementing Classes:
AbstractPort
,AbstractPortDecorator
,CrossoverLoopbackPort
,LoopbackPort
The
SegmentReceiver
is used to receive Segment
instances in a
unified way.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
-
Method Summary
Modifier and TypeMethodDescription<SEGMENT extends Segment>
SegmentResult<SEGMENT>onReceiveSegment
(SEGMENT aSegment) Asynchronously receives aSegment
'sSequence
data (does not block this thread) and updates theSegment
by invokingSegment.fromTransmission(Sequence)
.<SEGMENT extends Segment>
voidonReceiveSegment
(SEGMENT aSegment, SegmentConsumer<SEGMENT> aSegmentConsumer) Asynchronously receives aSegment
'sSequence
data (does not block this thread) and updates theSegment
by invokingSegment.fromTransmission(Sequence)
, passing the result to the callbackSegmentConsumer.onSegment(Segment)
.<SEGMENT extends Segment>
voidreceiveSegmentWithin
(long aTimeoutMillis, SEGMENT aSegment) Receives aSegment
(and blocks this thread) till all it'sSequence
data has been received and updates theSegment
by invokingSegment.fromTransmission(Sequence)
.Methods inherited from interface org.refcodes.io.Availability
available, hasAvailable
Methods inherited from interface org.refcodes.component.Closable
close, closeIn, closeQuietly, closeUnchecked
Methods inherited from interface org.refcodes.component.Closable.CloseAutomaton
isClosable
Methods inherited from interface org.refcodes.component.ClosedAccessor
isClosed
Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor
getConnectionStatus, isOpened
Methods inherited from interface org.refcodes.serial.SegmentDestination
receiveSegment
-
Method Details
-
receiveSegmentWithin
<SEGMENT extends Segment> void receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) throws TransmissionException, IOException Receives aSegment
(and blocks this thread) till all it'sSequence
data has been received and updates theSegment
by invokingSegment.fromTransmission(Sequence)
. This method blocks till all bytes are read or the timeout has been reached.- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass of implementingSegment
types.- Parameters:
aTimeoutMillis
- The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).aSegment
- TheSegment
to be (re-)initialized with the received data.- Throws:
TransmissionException
- Thrown in case the received data cannot be used to (re-)initialize the givenSegment
.IOException
- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
onReceiveSegment
<SEGMENT extends Segment> void onReceiveSegment(SEGMENT aSegment, SegmentConsumer<SEGMENT> aSegmentConsumer) throws IOException Asynchronously receives aSegment
'sSequence
data (does not block this thread) and updates theSegment
by invokingSegment.fromTransmission(Sequence)
, passing the result to the callbackSegmentConsumer.onSegment(Segment)
.- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass of implementingSegment
types.- Parameters:
aSegment
- TheSegment
to be (re-)initialized with the received data.aSegmentConsumer
- The callback asynchronously invoked upon having received theSegment
.- Throws:
IOException
- thrown in case of I/O issues (e.g. a closed connection) while receiving.
-
onReceiveSegment
<SEGMENT extends Segment> SegmentResult<SEGMENT> onReceiveSegment(SEGMENT aSegment) throws IOException Asynchronously receives aSegment
'sSequence
data (does not block this thread) and updates theSegment
by invokingSegment.fromTransmission(Sequence)
. The result is provided by the returnedSegmentResult
instance providing the (asynchronously) (re-)initialized providedSegment
instance.- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass used.- Parameters:
aSegment
- TheSegment
to be (re-)initialized with the received data.- Returns:
- The
SegmentResult
which provides the result (asynchronously). - Throws:
IOException
- thrown in case of I/O issues (e.g. a closed connection) while receiving.
-