- java.lang.Object
-
- org.refcodes.p2p.AbstractP2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence>
-
- 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.MagicNumberAccessor<Integer>,org.refcodes.mixin.Message<SerialP2PHeader,org.refcodes.serial.Sequence>,org.refcodes.p2p.P2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence>,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> implements org.refcodes.p2p.P2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence>, org.refcodes.serial.Segment, org.refcodes.serial.Segment.SegmentMixin, org.refcodes.mixin.MagicNumberAccessor<Integer>
Basic implementation of theP2PMessageoptimized for local area microcontroller wiring (networks) and microcontroller memory layout.- 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.mixin.MagicNumberAccessor
org.refcodes.mixin.MagicNumberAccessor.MagicNumberBuilder<T extends Object,B extends org.refcodes.mixin.MagicNumberAccessor.MagicNumberBuilder<T,B>>, org.refcodes.mixin.MagicNumberAccessor.MagicNumberMutator<T extends Object>, org.refcodes.mixin.MagicNumberAccessor.MagicNumberProperty<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAGIC_NUMBERDefault magic number in case none has been specified.
-
Constructor Summary
Constructors Constructor Description SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload)Constructs anSerialP2PMessage.SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload, org.refcodes.serial.TransmissionMetrics 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, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage.SerialP2PMessage(int aMagicNumber, int aDestination, P aPayload)Constructs anSerialP2PMessage.SerialP2PMessage(int aMagicNumber, int aDestination, P aPayload, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage.SerialP2PMessage(int aDestination, org.refcodes.serial.Segment aPayload)Constructs anSerialP2PMessage.SerialP2PMessage(int aDestination, org.refcodes.serial.Segment aPayload, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage.SerialP2PMessage(int aDestination, org.refcodes.serial.Sequence aPayload)Constructs anSerialP2PMessage.SerialP2PMessage(int aDestination, org.refcodes.serial.Sequence aPayload, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage.SerialP2PMessage(int aDestination, P aPayload)Constructs anSerialP2PMessage.SerialP2PMessage(int aDestination, P aPayload, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage.SerialP2PMessage(org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs an emptySerialP2PMessage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset)intgetLength()IntegergetMagicNumber()<P> PgetPayload(Class<P> aResponseType)voidreceiveFrom(InputStream aInputStream, OutputStream aFeedbackStream)org.refcodes.serial.SchematoSchema()org.refcodes.serial.SequencetoSequence()org.refcodes.struct.SimpleTypeMaptoSimpleTypeMap()voidtransmitTo(OutputStream aOutputStream, InputStream aReturnStream)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
DEFAULT_MAGIC_NUMBER
public static final int DEFAULT_MAGIC_NUMBER
Default magic number in case none has been specified.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SerialP2PMessage
public SerialP2PMessage(org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)
Constructs an emptySerialP2PMessage.- Parameters:
aTransmissionMetrics- the aTransmissionMetricsto 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, org.refcodes.serial.TransmissionMetrics 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 aTransmissionMetricsto 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 bytes to prefix to 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, org.refcodes.serial.TransmissionMetrics 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 bytes to prefix to this message when being transmitted.aDestination- The destination locator of the peer being addressed.aPayload- The payload to be sent.aTransmissionMetrics- the aTransmissionMetricsto 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 aDestination, org.refcodes.serial.Sequence aPayload, org.refcodes.serial.TransmissionMetrics 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 aTransmissionMetricsto use.
-
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 bytes to prefix to this message when being transmitted.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, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage. The source is added upon transmission as first stop-over.- Parameters:
aMagicNumber- The magic bytes to prefix to this message when being transmitted.aDestination- The destination locator of the peer being addressed.aPayload- the a payloadaTransmissionMetrics- the aTransmissionMetricsto use.
-
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 aDestination, org.refcodes.serial.Segment aPayload, org.refcodes.serial.TransmissionMetrics 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 aTransmissionMetricsto use.
-
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 bytes to prefix to 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, org.refcodes.serial.Sequence aPayload, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics)Constructs anSerialP2PMessage. The source is added upon transmission as first stop-over.- Parameters:
aMagicNumber- The magic bytes to prefix to this message when being transmitted.aDestination- The destination locator of the peer being addressed.aPayload- The payload to be sent.aTransmissionMetrics- the aTransmissionMetricsto use.
-
-
Method Detail
-
toSequence
public org.refcodes.serial.Sequence toSequence()
- Specified by:
toSequencein interfaceorg.refcodes.serial.Transmission
-
transmitTo
public void transmitTo(OutputStream aOutputStream, InputStream aReturnStream) throws IOException
- Specified by:
transmitToin interfaceorg.refcodes.serial.Transmission- Specified by:
transmitToin interfaceorg.refcodes.serial.Transmission.TransmissionMixin- Throws:
IOException
-
fromTransmission
public int fromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset) throws org.refcodes.serial.TransmissionException- Specified by:
fromTransmissionin 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:
receiveFromin interfaceorg.refcodes.serial.Segment- Specified by:
receiveFromin interfaceorg.refcodes.serial.Segment.SegmentMixin- Throws:
IOExceptionorg.refcodes.serial.TransmissionException
-
toSchema
public org.refcodes.serial.Schema toSchema()
- Specified by:
toSchemain interfaceorg.refcodes.serial.Transmission
-
getLength
public int getLength()
- Specified by:
getLengthin interfaceorg.refcodes.mixin.LengthAccessor- Specified by:
getLengthin interfaceorg.refcodes.serial.Transmission
-
toSimpleTypeMap
public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
- Specified by:
toSimpleTypeMapin interfaceorg.refcodes.serial.Transmission
-
getPayload
public <P> P getPayload(Class<P> aResponseType) throws org.refcodes.exception.UnmarshalException
- Specified by:
getPayloadin interfaceorg.refcodes.p2p.P2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence>- Throws:
org.refcodes.exception.UnmarshalException
-
-