java.lang.Object
org.refcodes.p2p.AbstractP2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence,SerialP2PTail>
org.refcodes.p2p.alt.serial.SerialP2PMessage
- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.BodyAccessor<org.refcodes.serial.Sequence>
,org.refcodes.mixin.HeaderAccessor<SerialP2PHeader>
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.Message<SerialP2PHeader,
,org.refcodes.serial.Sequence> org.refcodes.mixin.Schemable
,org.refcodes.mixin.TailAccessor<SerialP2PTail>
,org.refcodes.p2p.P2PMessage<Integer,
,SerialP2PHeader, org.refcodes.serial.Sequence, SerialP2PTail> org.refcodes.serial.Segment
,org.refcodes.serial.Segment.SegmentMixin
,org.refcodes.serial.Transmission
,org.refcodes.serial.Transmission.TransmissionMixin
public class SerialP2PMessage
extends org.refcodes.p2p.AbstractP2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence,SerialP2PTail>
implements org.refcodes.serial.Segment, org.refcodes.serial.Segment.SegmentMixin
Basic implementation of the
P2PMessage
optimized for local area
microcontroller wiring (networks) and microcontroller memory layout: The hops
are serialized and deserialized in the tail of the SerialP2PMessage
as this makes append the last hop easier for devices with small memory
buffers.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.BodyAccessor
org.refcodes.mixin.BodyAccessor.BodyBuilder<T extends Object,
B extends org.refcodes.mixin.BodyAccessor.BodyBuilder<T, B>>, org.refcodes.mixin.BodyAccessor.BodyMutator<T extends Object>, org.refcodes.mixin.BodyAccessor.BodyProperty<T extends Object> Nested classes/interfaces inherited from interface org.refcodes.mixin.HeaderAccessor
org.refcodes.mixin.HeaderAccessor.HeaderBuilder<T extends Object,
B extends org.refcodes.mixin.HeaderAccessor.HeaderBuilder<T, B>>, org.refcodes.mixin.HeaderAccessor.HeaderMutator<T extends Object>, org.refcodes.mixin.HeaderAccessor.HeaderProperty<T extends Object> Nested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.Segment
org.refcodes.serial.Segment.SegmentMixin
Nested classes/interfaces inherited from interface org.refcodes.mixin.TailAccessor
org.refcodes.mixin.TailAccessor.TailBuilder<T extends Object,
B extends org.refcodes.mixin.TailAccessor.TailBuilder<T, B>>, org.refcodes.mixin.TailAccessor.TailMutator<T extends Object>, org.refcodes.mixin.TailAccessor.TailProperty<T extends Object> Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
org.refcodes.serial.Transmission.TransmissionMixin
-
Field Summary
Fields inherited from class org.refcodes.p2p.AbstractP2PMessage
_body, _header, _tail
-
Constructor Summary
ConstructorDescriptionConstructs an emptySerialP2PMessage
.SerialP2PMessage
(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aMagicNumber, int aDestination, P aPayload) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aMagicNumber, int aDestination, P aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aDestination, org.refcodes.serial.Segment aPayload) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aDestination, org.refcodes.serial.Segment aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aDestination, org.refcodes.serial.Sequence aPayload) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aDestination, org.refcodes.serial.Sequence aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aDestination, P aPayload) Constructs anSerialP2PMessage
.SerialP2PMessage
(int aDestination, P aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
.SerialP2PMessage
(SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs an emptySerialP2PMessage
. -
Method Summary
Modifier and TypeMethodDescriptionint
fromTransmission
(org.refcodes.serial.Sequence aSequence, int aOffset) int
<P> P
getPayload
(Class<P> aResponseType) void
receiveFrom
(InputStream aInputStream, OutputStream aFeedbackStream) org.refcodes.serial.SerialSchema
toSchema()
org.refcodes.serial.Sequence
org.refcodes.struct.SimpleTypeMap
void
transmitTo
(OutputStream aOutputStream, InputStream aReturnStream) Methods inherited from class org.refcodes.p2p.AbstractP2PMessage
getBody, getHeader, getTail, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
Methods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
-
Constructor Details
-
SerialP2PMessage
public SerialP2PMessage()Constructs an emptySerialP2PMessage
. -
SerialP2PMessage
Constructs an emptySerialP2PMessage
.- Parameters:
aTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
SerialP2PMessage
public SerialP2PMessage(int aDestination, P aPayload) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Type Parameters:
P
- The type of the payload in question.- Parameters:
aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.
-
SerialP2PMessage
public SerialP2PMessage(int aDestination, P aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Type Parameters:
P
- The type of the payload in question.- Parameters:
aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.aTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
SerialP2PMessage
public SerialP2PMessage(int aMagicNumber, int aDestination, P aPayload) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Type Parameters:
P
- The type of the payload in question.- Parameters:
aMagicNumber
- The magic number for tagging this message when being transmitted.aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.
-
SerialP2PMessage
public SerialP2PMessage(int aMagicNumber, int aDestination, P aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Type Parameters:
P
- The type of the payload in question.- Parameters:
aMagicNumber
- The magic number for tagging this message when being transmitted.aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.aTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
SerialP2PMessage
public SerialP2PMessage(int aDestination, org.refcodes.serial.Sequence aPayload) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aDestination
- The destination locator of the peer being addressed.aPayload
- the a payload
-
SerialP2PMessage
public SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aMagicNumber
- The magic number for tagging this message when being transmitted.aDestination
- The destination locator of the peer being addressed.aPayload
- the a payload
-
SerialP2PMessage
public SerialP2PMessage(int aDestination, org.refcodes.serial.Segment aPayload) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aDestination
- The destination locator of the peer being addressed.aPayload
- the a payload
-
SerialP2PMessage
public SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aMagicNumber
- The magic number for tagging this message when being transmitted.aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.
-
SerialP2PMessage
public SerialP2PMessage(int aDestination, org.refcodes.serial.Segment aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aDestination
- The destination locator of the peer being addressed.aPayload
- the a payloadaTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
SerialP2PMessage
public SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aMagicNumber
- The magic number for tagging this message when being transmitted..aDestination
- The destination locator of the peer being addressed.aPayload
- the a payloadaTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
SerialP2PMessage
public SerialP2PMessage(int aDestination, org.refcodes.serial.Sequence aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.aTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
SerialP2PMessage
public SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics) Constructs anSerialP2PMessage
. The source is added upon transmission as first stop-over.- Parameters:
aMagicNumber
- The magic number for tagging this message when being transmitted.aDestination
- The destination locator of the peer being addressed.aPayload
- The payload to be sent.aTransmissionMetrics
- the aSerialP2PTransmissionMetrics
to use.
-
-
Method Details
-
fromTransmission
public int fromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset) throws org.refcodes.serial.TransmissionException - Specified by:
fromTransmission
in interfaceorg.refcodes.serial.Segment
- Throws:
org.refcodes.serial.TransmissionException
-
receiveFrom
- Specified by:
receiveFrom
in interfaceorg.refcodes.serial.Segment
- Specified by:
receiveFrom
in interfaceorg.refcodes.serial.Segment.SegmentMixin
- Throws:
IOException
-
toSequence
public org.refcodes.serial.Sequence toSequence()- Specified by:
toSequence
in interfaceorg.refcodes.serial.Transmission
-
transmitTo
- Specified by:
transmitTo
in interfaceorg.refcodes.serial.Transmission
- Specified by:
transmitTo
in interfaceorg.refcodes.serial.Transmission.TransmissionMixin
- Throws:
IOException
-
toSchema
public org.refcodes.serial.SerialSchema toSchema()- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable
- Specified by:
toSchema
in interfaceorg.refcodes.serial.Transmission
-
getLength
public int getLength()- Specified by:
getLength
in interfaceorg.refcodes.mixin.LengthAccessor
- Specified by:
getLength
in interfaceorg.refcodes.serial.Transmission
-
toSimpleTypeMap
public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()- Specified by:
toSimpleTypeMap
in interfaceorg.refcodes.serial.Transmission
-
getPayload
- Specified by:
getPayload
in interfaceorg.refcodes.p2p.P2PMessage<Integer,
SerialP2PHeader, org.refcodes.serial.Sequence, SerialP2PTail> - Throws:
org.refcodes.exception.UnmarshalException
-