Module org.refcodes.p2p
Package org.refcodes.p2p
Interface PeerRouter<LOCATOR,HEADER extends P2PHeader<LOCATOR>,MSG extends P2PMessage<LOCATOR,HEADER,?>>
-
- Type Parameters:
LOCATOR
- The locator defines the type which identifies a source and a destination (or stop-overs) of aP2PMessage
.HEADER
- TheP2PHeader
defines the least required attributes of aP2PMessage
.MSG
- The (sub-)type of theP2PMessage
being processed by the accordingPeer
(sub-)type.
- All Known Implementing Classes:
AbstractPeer
public interface PeerRouter<LOCATOR,HEADER extends P2PHeader<LOCATOR>,MSG extends P2PMessage<LOCATOR,HEADER,?>>
APeerRouter
defines functionality to route aP2PMessage
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default int
getHopCount(LOCATOR aDestination)
Determines the (nearest) hop count to the given peer.int
getHopCount(LOCATOR aLocator, LOCATOR[] aHops)
Determines the (nearest) hop count to the given peer.void
sendMessage(MSG aMessage)
Passes a message to the given peer.
-
-
-
Method Detail
-
getHopCount
default int getHopCount(LOCATOR aDestination) throws IOException
Determines the (nearest) hop count to the given peer.- Parameters:
aDestination
- The unique ID of the peer for which to get the hop count.- Returns:
- The according hop count or -1 if the targeted peer is unreachable.
- Throws:
IOException
- thrown in case I/O problems occurred while accessing the mesh.
-
getHopCount
int getHopCount(LOCATOR aLocator, LOCATOR[] aHops) throws IOException
Determines the (nearest) hop count to the given peer.- Parameters:
aLocator
- The unique ID of the peer for which to get the hop count.aHops
- The trail of peers already passed (in order to avoid turning circles when determining the hop count).- Returns:
- The according hop count or -1 if the targeted peer is unreachable.
- Throws:
IOException
- thrown in case I/O problems occurred while accessing the mesh.
-
sendMessage
void sendMessage(MSG aMessage) throws NoSuchDestinationException, IOException
Passes a message to the given peer.- Parameters:
aMessage
- The message to be passed.- Throws:
NoSuchDestinationException
- thrown in case there is none such destination peer.IOException
- thrown in case I/O problems occurred while accessing the mesh.
-
-