Class SerialPeer

java.lang.Object
org.refcodes.p2p.AbstractPeer<Integer,SerialP2PHeader,SerialP2PTail,SerialP2PMessage,org.refcodes.p2p.P2PMessageConsumer<SerialP2PMessage,SerialPeer>,SerialPeer,SerialPeerRouter>
org.refcodes.p2p.alt.serial.SerialPeer
All Implemented Interfaces:
org.refcodes.mixin.LocatorAccessor<Integer>, SerialPeerRouter, org.refcodes.p2p.Peer<Integer,SerialP2PHeader,SerialP2PTail,SerialP2PMessage,SerialPeerRouter>, org.refcodes.p2p.PeerRouter<Integer,SerialP2PHeader,SerialP2PTail,SerialP2PMessage>, org.refcodes.p2p.Terminal<Integer>

public class SerialPeer extends org.refcodes.p2p.AbstractPeer<Integer,SerialP2PHeader,SerialP2PTail,SerialP2PMessage,org.refcodes.p2p.P2PMessageConsumer<SerialP2PMessage,SerialPeer>,SerialPeer,SerialPeerRouter> implements org.refcodes.p2p.Peer<Integer,SerialP2PHeader,SerialP2PTail,SerialP2PMessage,SerialPeerRouter>, SerialPeerRouter
The SerialPeer implements a Peer optimized for local area microcontroller wiring (networks) and microcontroller memory layout.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.refcodes.mixin.LocatorAccessor

    org.refcodes.mixin.LocatorAccessor.LocatorBuilder<T extends Object,B extends org.refcodes.mixin.LocatorAccessor.LocatorBuilder<T,B>>, org.refcodes.mixin.LocatorAccessor.LocatorMutator<T extends Object>, org.refcodes.mixin.LocatorAccessor.LocatorProperty<T extends Object>
  • Field Summary

    Fields inherited from class org.refcodes.p2p.AbstractPeer

    _locator, _messageConsumer, _peerRouter
  • Constructor Summary

    Constructors
    Constructor
    Description
    SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService, org.refcodes.serial.Port<?>... aPorts)
    Constructs the Peer instance with the given locator identifying the Peer and the given P2PMessageConsumer processing the messages targeted at the given locator binding the given Port instances.
    SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, org.refcodes.serial.Port<?>... aPorts)
    Constructs the Peer instance with the given locator identifying the Peer and the given P2PMessageConsumer processing the messages targeted at the given locator binding the given Port instances.
    SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.Port<?>... aPorts)
    Constructs the Peer instance with the given locator identifying the Peer and the given P2PMessageConsumer processing the messages targeted at the given locator binding the given Port instances.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    sendMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload)
    Convenience method for AbstractPeer.sendMessage(P2PMessage).
    void
    sendMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload)
    Convenience method for AbstractPeer.sendMessage(P2PMessage).
    <P> void
    sendMessage(int aMagicNumber, int aDestination, P aPayload)
    Convenience method for AbstractPeer.sendMessage(P2PMessage).
    void
    sendMessage(int aDestination, org.refcodes.serial.Segment aPayload)
    Convenience method for AbstractPeer.sendMessage(P2PMessage).
    void
    sendMessage(int aDestination, org.refcodes.serial.Sequence aPayload)
    Convenience method for AbstractPeer.sendMessage(P2PMessage).
    <P> void
    sendMessage(Integer aDestination, P aPayload)

    Methods inherited from class org.refcodes.p2p.AbstractPeer

    addPeerRouter, getHopCount, getLocator, peerRouters, removePeerRouter, sendMessage, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.refcodes.mixin.LocatorAccessor

    getLocator

    Methods inherited from interface org.refcodes.p2p.Peer

    addPeerRouter, peerRouters, removePeerRouter

    Methods inherited from interface org.refcodes.p2p.PeerRouter

    getHopCount, getHopCount, sendMessage
  • Constructor Details

    • SerialPeer

      public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.Port<?>... aPorts)
      Constructs the Peer instance with the given locator identifying the Peer and the given P2PMessageConsumer processing the messages targeted at the given locator binding the given Port instances.
      Parameters:
      aLocator - The LOCATOR of the Peer being constructed. Messages targeted to this Peer will be addressed to the given LOCATOR.
      aMessageConsumer - The consumer (being the functional P2PMessageConsumer interface) of the P2PMessage instances targeted at this Peer instance.
      aPorts - The Port instances to which to attach.
    • SerialPeer

      public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, org.refcodes.serial.Port<?>... aPorts)
      Constructs the Peer instance with the given locator identifying the Peer and the given P2PMessageConsumer processing the messages targeted at the given locator binding the given Port instances.
      Parameters:
      aLocator - The LOCATOR of the Peer being constructed. Messages targeted to this Peer will be addressed to the given LOCATOR.
      aMessageConsumer - The consumer (being the functional P2PMessageConsumer interface) of the P2PMessage instances targeted at this Peer instance.
      aTransmissionMetrics - The SerialP2PTransmissionMetrics to use when setting up the peer.
      aPorts - The Port instances to which to attach.
    • SerialPeer

      public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService, org.refcodes.serial.Port<?>... aPorts)
      Constructs the Peer instance with the given locator identifying the Peer and the given P2PMessageConsumer processing the messages targeted at the given locator binding the given Port instances.
      Parameters:
      aLocator - The LOCATOR of the Peer being constructed. Messages targeted to this Peer will be addressed to the given LOCATOR.
      aMessageConsumer - The consumer (being the functional P2PMessageConsumer interface) of the P2PMessage instances targeted at this Peer instance.
      aTransmissionMetrics - The SerialP2PTransmissionMetrics to use when setting up the peer.
      aExecutorService - The ExecutorService to be used when creating Thread instances for handling input and output data simultaneously.
      aPorts - The Port instances to which to attach.
  • Method Details

    • sendMessage

      public <P> void sendMessage(Integer aDestination, P aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
      Specified by:
      sendMessage in interface org.refcodes.p2p.Peer<Integer,SerialP2PHeader,SerialP2PTail,SerialP2PMessage,SerialPeerRouter>
      Throws:
      IOException
      org.refcodes.p2p.NoSuchDestinationException
    • sendMessage

      public void sendMessage(int aDestination, org.refcodes.serial.Segment aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
      Convenience method for AbstractPeer.sendMessage(P2PMessage).
      Parameters:
      aDestination - The destination of the message.
      aPayload - The payload to be sent.
      Throws:
      IOException - thrown in case I/O problems occurred while accessing the mesh.
      org.refcodes.p2p.NoSuchDestinationException - thrown in case there is none such destination peer.
    • sendMessage

      public void sendMessage(int aDestination, org.refcodes.serial.Sequence aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
      Convenience method for AbstractPeer.sendMessage(P2PMessage).
      Parameters:
      aDestination - The destination of the message.
      aPayload - The payload to be sent.
      Throws:
      IOException - thrown in case I/O problems occurred while accessing the mesh.
      org.refcodes.p2p.NoSuchDestinationException - thrown in case there is none such destination peer.
    • sendMessage

      public <P> void sendMessage(int aMagicNumber, int aDestination, P aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
      Convenience method for AbstractPeer.sendMessage(P2PMessage).
      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 of the message.
      aPayload - The payload to be sent.
      Throws:
      IOException - thrown in case I/O problems occurred while accessing the mesh.
      org.refcodes.p2p.NoSuchDestinationException - thrown in case there is none such destination peer.
    • sendMessage

      public void sendMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
      Convenience method for AbstractPeer.sendMessage(P2PMessage).
      Parameters:
      aMagicNumber - The magic number for tagging this message when being transmitted.
      aDestination - The destination of the message.
      aPayload - The payload to be sent.
      Throws:
      IOException - thrown in case I/O problems occurred while accessing the mesh.
      org.refcodes.p2p.NoSuchDestinationException - thrown in case there is none such destination peer.
    • sendMessage

      public void sendMessage(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
      Convenience method for AbstractPeer.sendMessage(P2PMessage).
      Parameters:
      aMagicNumber - The magic number for tagging this message when being transmitted.
      aDestination - The destination of the message.
      aPayload - The payload to be sent.
      Throws:
      IOException - thrown in case I/O problems occurred while accessing the mesh.
      org.refcodes.p2p.NoSuchDestinationException - thrown in case there is none such destination peer.