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
ConstructorDescriptionSerialPeer
(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService, org.refcodes.serial.Port<?>... aPorts) Constructs thePeer
instance with the given locator identifying thePeer
and the givenP2PMessageConsumer
processing the messages targeted at the given locator binding the givenPort
instances.SerialPeer
(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, org.refcodes.serial.Port<?>... aPorts) Constructs thePeer
instance with the given locator identifying thePeer
and the givenP2PMessageConsumer
processing the messages targeted at the given locator binding the givenPort
instances.SerialPeer
(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.Port<?>... aPorts) Constructs thePeer
instance with the given locator identifying thePeer
and the givenP2PMessageConsumer
processing the messages targeted at the given locator binding the givenPort
instances. -
Method Summary
Modifier and TypeMethodDescriptionvoid
sendMessage
(int aMagicNumber, int aDestination, org.refcodes.serial.Segment aPayload) Convenience method forAbstractPeer.sendMessage(P2PMessage)
.void
sendMessage
(int aMagicNumber, int aDestination, org.refcodes.serial.Sequence aPayload) Convenience method forAbstractPeer.sendMessage(P2PMessage)
.<P> void
sendMessage
(int aMagicNumber, int aDestination, P aPayload) Convenience method forAbstractPeer.sendMessage(P2PMessage)
.void
sendMessage
(int aDestination, org.refcodes.serial.Segment aPayload) Convenience method forAbstractPeer.sendMessage(P2PMessage)
.void
sendMessage
(int aDestination, org.refcodes.serial.Sequence aPayload) Convenience method forAbstractPeer.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 thePeer
instance with the given locator identifying thePeer
and the givenP2PMessageConsumer
processing the messages targeted at the given locator binding the givenPort
instances.- Parameters:
aLocator
- The LOCATOR of thePeer
being constructed. Messages targeted to thisPeer
will be addressed to the given LOCATOR.aMessageConsumer
- The consumer (being the functionalP2PMessageConsumer
interface) of theP2PMessage
instances targeted at thisPeer
instance.aPorts
- ThePort
instances to which to attach.
-
SerialPeer
public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, org.refcodes.serial.Port<?>... aPorts) Constructs thePeer
instance with the given locator identifying thePeer
and the givenP2PMessageConsumer
processing the messages targeted at the given locator binding the givenPort
instances.- Parameters:
aLocator
- The LOCATOR of thePeer
being constructed. Messages targeted to thisPeer
will be addressed to the given LOCATOR.aMessageConsumer
- The consumer (being the functionalP2PMessageConsumer
interface) of theP2PMessage
instances targeted at thisPeer
instance.aTransmissionMetrics
- TheSerialP2PTransmissionMetrics
to use when setting up the peer.aPorts
- ThePort
instances to which to attach.
-
SerialPeer
public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, SerialP2PTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService, org.refcodes.serial.Port<?>... aPorts) Constructs thePeer
instance with the given locator identifying thePeer
and the givenP2PMessageConsumer
processing the messages targeted at the given locator binding the givenPort
instances.- Parameters:
aLocator
- The LOCATOR of thePeer
being constructed. Messages targeted to thisPeer
will be addressed to the given LOCATOR.aMessageConsumer
- The consumer (being the functionalP2PMessageConsumer
interface) of theP2PMessage
instances targeted at thisPeer
instance.aTransmissionMetrics
- TheSerialP2PTransmissionMetrics
to use when setting up the peer.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.aPorts
- ThePort
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 interfaceorg.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 forAbstractPeer.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 forAbstractPeer.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 forAbstractPeer.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 forAbstractPeer.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 forAbstractPeer.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.
-