- 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.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.p2p.P2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence,SerialP2PTail>, org.refcodes.serial.Segment, org.refcodes.serial.Segment.SegmentMixin
Basic implementation of theP2PMessage
optimized for local area microcontroller wiring (networks) and microcontroller memory layout: The hops are serialized and deserialized in the tail of theSerialP2PMessage
as this makes append the last hop easier for devices with small memory buffers.- See Also:
- Serialized Form
-
-
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>
-
-
Constructor Summary
Constructors Constructor Description SerialP2PMessage()
Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
fromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset)
int
getLength()
<P> P
getPayload(Class<P> aResponseType)
void
receiveFrom(InputStream aInputStream, OutputStream aFeedbackStream)
org.refcodes.serial.Schema
toSchema()
org.refcodes.serial.Sequence
toSequence()
org.refcodes.struct.SimpleTypeMap
toSimpleTypeMap()
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
-
-
-
-
Constructor Detail
-
SerialP2PMessage
public SerialP2PMessage()
Constructs an emptySerialP2PMessage
.
-
SerialP2PMessage
public SerialP2PMessage(SerialP2PTransmissionMetrics aTransmissionMetrics)
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 Detail
-
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
public void receiveFrom(InputStream aInputStream, OutputStream aFeedbackStream) throws IOException, org.refcodes.serial.TransmissionException
- Specified by:
receiveFrom
in interfaceorg.refcodes.serial.Segment
- Specified by:
receiveFrom
in interfaceorg.refcodes.serial.Segment.SegmentMixin
- Throws:
IOException
org.refcodes.serial.TransmissionException
-
toSequence
public org.refcodes.serial.Sequence toSequence()
- Specified by:
toSequence
in interfaceorg.refcodes.serial.Transmission
-
transmitTo
public void transmitTo(OutputStream aOutputStream, InputStream aReturnStream) throws IOException
- Specified by:
transmitTo
in interfaceorg.refcodes.serial.Transmission
- Specified by:
transmitTo
in interfaceorg.refcodes.serial.Transmission.TransmissionMixin
- Throws:
IOException
-
toSchema
public org.refcodes.serial.Schema toSchema()
- 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
public <P> P getPayload(Class<P> aResponseType) throws org.refcodes.exception.UnmarshalException
- Specified by:
getPayload
in interfaceorg.refcodes.p2p.P2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence,SerialP2PTail>
- Throws:
org.refcodes.exception.UnmarshalException
-
-