- java.lang.Object
-
- org.refcodes.p2p.AbstractPeer<Integer,SerialP2PHeader,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,SerialP2PMessage,SerialPeerRouter>,org.refcodes.p2p.PeerRouter<Integer,SerialP2PHeader,SerialP2PMessage>,org.refcodes.p2p.Terminal<Integer>
public class SerialPeer extends org.refcodes.p2p.AbstractPeer<Integer,SerialP2PHeader,SerialP2PMessage,org.refcodes.p2p.P2PMessageConsumer<SerialP2PMessage,SerialPeer>,SerialPeer,SerialPeerRouter> implements org.refcodes.p2p.Peer<Integer,SerialP2PHeader,SerialP2PMessage,SerialPeerRouter>, SerialPeerRouter
TheSerialPeerimplements aPeeroptimized 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>
-
-
Constructor Summary
Constructors Constructor Description SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.Port<?>... aPorts)Constructs thePeerinstance with the given locator identifying thePeerand the givenP2PMessageConsumerprocessing the messages targeted at the given locator binding the givenPortinstances.SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService, org.refcodes.serial.Port<?>... aPorts)Constructs thePeerinstance with the given locator identifying thePeerand the givenP2PMessageConsumerprocessing the messages targeted at the given locator binding the givenPortinstances.SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics, org.refcodes.serial.Port<?>... aPorts)Constructs thePeerinstance with the given locator identifying thePeerand the givenP2PMessageConsumerprocessing the messages targeted at the given locator binding the givenPortinstances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsendMessage(int aDestination, org.refcodes.serial.Segment aPayload)Convenience method forAbstractPeer.sendMessage(P2PMessage).voidsendMessage(int aDestination, org.refcodes.serial.Sequence aPayload)Convenience method forAbstractPeer.sendMessage(P2PMessage).<P> voidsendMessage(Integer aDestination, P aPayload)-
Methods inherited from class org.refcodes.p2p.AbstractPeer
addPeerRouter, getHopCount, getLocator, peerRouters, removePeerRouter, sendMessage, toString
-
-
-
-
Constructor Detail
-
SerialPeer
public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.Port<?>... aPorts)
Constructs thePeerinstance with the given locator identifying thePeerand the givenP2PMessageConsumerprocessing the messages targeted at the given locator binding the givenPortinstances.- Parameters:
aLocator- The LOCATOR of thePeerbeing constructed. Messages targeted to thisPeerwill be addressed to the given LOCATOR.aMessageConsumer- The consumer (being the functionalP2PMessageConsumerinterface) of theP2PMessageinstances targeted at thisPeerinstance.aPorts- ThePortinstances to which to attach.
-
SerialPeer
public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics, org.refcodes.serial.Port<?>... aPorts)
Constructs thePeerinstance with the given locator identifying thePeerand the givenP2PMessageConsumerprocessing the messages targeted at the given locator binding the givenPortinstances.- Parameters:
aLocator- The LOCATOR of thePeerbeing constructed. Messages targeted to thisPeerwill be addressed to the given LOCATOR.aMessageConsumer- The consumer (being the functionalP2PMessageConsumerinterface) of theP2PMessageinstances targeted at thisPeerinstance.aTransmissionMetrics- TheTransmissionMetricsto use when setting up the peer.aPorts- ThePortinstances to which to attach.
-
SerialPeer
public SerialPeer(Integer aLocator, SerialP2PMessageConsumer aMessageConsumer, org.refcodes.serial.TransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService, org.refcodes.serial.Port<?>... aPorts)
Constructs thePeerinstance with the given locator identifying thePeerand the givenP2PMessageConsumerprocessing the messages targeted at the given locator binding the givenPortinstances.- Parameters:
aLocator- The LOCATOR of thePeerbeing constructed. Messages targeted to thisPeerwill be addressed to the given LOCATOR.aMessageConsumer- The consumer (being the functionalP2PMessageConsumerinterface) of theP2PMessageinstances targeted at thisPeerinstance.aTransmissionMetrics- TheTransmissionMetricsto use when setting up the peer.aExecutorService- TheExecutorServiceto be used when creatingThreadinstances for handling input and output data simultaneously.aPorts- ThePortinstances to which to attach.
-
-
Method Detail
-
sendMessage
public <P> void sendMessage(Integer aDestination, P aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationException
- Specified by:
sendMessagein interfaceorg.refcodes.p2p.Peer<Integer,SerialP2PHeader,SerialP2PMessage,SerialPeerRouter>- Throws:
IOExceptionorg.refcodes.p2p.NoSuchDestinationException
-
sendMessage
public void sendMessage(int aDestination, org.refcodes.serial.Segment aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationExceptionConvenience method forAbstractPeer.sendMessage(P2PMessage).- Parameters:
aDestination- The destination of the message.aPayload- The payload to be sent.- Throws:
org.refcodes.p2p.NoSuchDestinationException- thrown in case there is none such destination peer.IOException- thrown in case I/O problems occurred while accessing the mesh.
-
sendMessage
public void sendMessage(int aDestination, org.refcodes.serial.Sequence aPayload) throws IOException, org.refcodes.p2p.NoSuchDestinationExceptionConvenience method forAbstractPeer.sendMessage(P2PMessage).- Parameters:
aDestination- The destination of the message.aPayload- The payload to be sent.- Throws:
org.refcodes.p2p.NoSuchDestinationException- thrown in case there is none such destination peer.IOException- thrown in case I/O problems occurred while accessing the mesh.
-
-