Class SerialP2PMessage

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:
  • Constructor Details

    • SerialP2PMessage

      public SerialP2PMessage()
      Constructs an empty SerialP2PMessage.
    • SerialP2PMessage

      public SerialP2PMessage(SerialP2PTransmissionMetrics aTransmissionMetrics)
      Constructs an empty SerialP2PMessage.
      Parameters:
      aTransmissionMetrics - the a SerialP2PTransmissionMetrics to use.
    • SerialP2PMessage

      public SerialP2PMessage(int aDestination, P aPayload)
      Constructs an SerialP2PMessage. 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 an SerialP2PMessage. 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 a SerialP2PTransmissionMetrics to use.
    • SerialP2PMessage

      public SerialP2PMessage(int aMagicNumber, int aDestination, P aPayload)
      Constructs an SerialP2PMessage. 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 an SerialP2PMessage. 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 a SerialP2PTransmissionMetrics to use.
    • SerialP2PMessage

      public SerialP2PMessage(int aDestination, org.refcodes.serial.Sequence aPayload)
      Constructs an SerialP2PMessage. 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 an SerialP2PMessage. 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 an SerialP2PMessage. 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 an SerialP2PMessage. 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 an SerialP2PMessage. The source is added upon transmission as first stop-over.
      Parameters:
      aDestination - The destination locator of the peer being addressed.
      aPayload - the a payload
      aTransmissionMetrics - the a SerialP2PTransmissionMetrics to use.
    • SerialP2PMessage

      public SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics)
      Constructs an SerialP2PMessage. 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
      aTransmissionMetrics - the a SerialP2PTransmissionMetrics to use.
    • SerialP2PMessage

      public SerialP2PMessage(int aDestination, org.refcodes.serial.Sequence aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics)
      Constructs an SerialP2PMessage. 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 a SerialP2PTransmissionMetrics to use.
    • SerialP2PMessage

      public SerialP2PMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload, SerialP2PTransmissionMetrics aTransmissionMetrics)
      Constructs an SerialP2PMessage. 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 a SerialP2PTransmissionMetrics to use.
  • Method Details

    • fromTransmission

      public int fromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset) throws org.refcodes.serial.TransmissionException
      Specified by:
      fromTransmission in interface org.refcodes.serial.Segment
      Throws:
      org.refcodes.serial.TransmissionException
    • receiveFrom

      public void receiveFrom(InputStream aInputStream, OutputStream aFeedbackStream) throws IOException
      Specified by:
      receiveFrom in interface org.refcodes.serial.Segment
      Specified by:
      receiveFrom in interface org.refcodes.serial.Segment.SegmentMixin
      Throws:
      IOException
    • toSequence

      public org.refcodes.serial.Sequence toSequence()
      Specified by:
      toSequence in interface org.refcodes.serial.Transmission
    • transmitTo

      public void transmitTo(OutputStream aOutputStream, InputStream aReturnStream) throws IOException
      Specified by:
      transmitTo in interface org.refcodes.serial.Transmission
      Specified by:
      transmitTo in interface org.refcodes.serial.Transmission.TransmissionMixin
      Throws:
      IOException
    • toSchema

      public org.refcodes.serial.SerialSchema toSchema()
      Specified by:
      toSchema in interface org.refcodes.mixin.Schemable
      Specified by:
      toSchema in interface org.refcodes.serial.Transmission
    • getLength

      public int getLength()
      Specified by:
      getLength in interface org.refcodes.mixin.LengthAccessor
      Specified by:
      getLength in interface org.refcodes.serial.Transmission
    • toSimpleTypeMap

      public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
      Specified by:
      toSimpleTypeMap in interface org.refcodes.serial.Transmission
    • getPayload

      public <P> P getPayload(Class<P> aResponseType) throws org.refcodes.exception.UnmarshalException
      Specified by:
      getPayload in interface org.refcodes.p2p.P2PMessage<Integer,SerialP2PHeader,org.refcodes.serial.Sequence,SerialP2PTail>
      Throws:
      org.refcodes.exception.UnmarshalException