Module org.refcodes.p2p
Package org.refcodes.p2p
Interface PeerRouter<LOCATOR,HEADER extends P2PHeader<LOCATOR>,TAIL extends P2PTail<LOCATOR>,MSG extends P2PMessage<LOCATOR,HEADER,?,TAIL>>
- Type Parameters:
LOCATOR
- Defines the type of the locators identifying a peer.HEADER
- TheP2PHeader
defines the static attributes addressed for the target of theP2PMessage
(a header might be signed as it is not modified during dispatch).TAIL
- TheP2PTail
describes the dynamic attributes required during dispatch of aP2PMessage
(a tail is modified during dispatch by having the visited hops appended).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>,TAIL extends P2PTail<LOCATOR>,MSG extends P2PMessage<LOCATOR,HEADER,?,TAIL>>
A
PeerRouter
defines functionality to route a P2PMessage
.-
Method Summary
Modifier and TypeMethodDescriptiondefault 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 Details
-
getHopCount
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
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
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.
-