Package org.drasyl.remote.handler
Class InternetDiscoveryHandler
- java.lang.Object
-
- org.drasyl.pipeline.skeleton.HandlerAdapter
-
- org.drasyl.pipeline.skeleton.AddressHandlerAdapter<A>
-
- org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler<I,E,A>
-
- org.drasyl.pipeline.skeleton.SimpleDuplexEventAwareHandler<I,Event,O,A>
-
- org.drasyl.pipeline.skeleton.SimpleDuplexHandler<AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite>,SerializedApplicationMessage,Address>
-
- org.drasyl.remote.handler.InternetDiscoveryHandler
-
- All Implemented Interfaces:
Handler
public class InternetDiscoveryHandler extends SimpleDuplexHandler<AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite>,SerializedApplicationMessage,Address>
This handler performs the following tasks, which help to communicate with nodes located in other networks:- Joins one or more super peers or acts itself as a super peer (super peers act as registries of available nodes on the network. they can be used as message relays and help to traverse NATs).
- Tracks which nodes are being communicated with and tries to establish direct connections to these nodes with the help of a super peer.
- Routes messages to the recipient. If no route is known, the message is relayed to a super peer (our default gateway).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InternetDiscoveryHandler.Ping
-
Field Summary
Fields Modifier and Type Field Description static String
INTERNET_DISCOVERY_HANDLER
-
Constructor Summary
Constructors Constructor Description InternetDiscoveryHandler(DrasylConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.protected void
matchedRead(HandlerContext ctx, Address sender, AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite> envelope, CompletableFuture<Void> future)
Is called for each message of typeSimpleInboundEventAwareHandler
.protected void
matchedWrite(HandlerContext ctx, Address recipient, SerializedApplicationMessage msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleDuplexEventAwareHandler
.-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleDuplexHandler
matchedEventTriggered
-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleDuplexEventAwareHandler
acceptOutbound, write
-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler
acceptEvent, acceptInbound, read
-
Methods inherited from class org.drasyl.pipeline.skeleton.AddressHandlerAdapter
acceptAddress
-
Methods inherited from class org.drasyl.pipeline.skeleton.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved
-
-
-
-
Field Detail
-
INTERNET_DISCOVERY_HANDLER
public static final String INTERNET_DISCOVERY_HANDLER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InternetDiscoveryHandler
public InternetDiscoveryHandler(DrasylConfig config)
-
-
Method Detail
-
eventTriggered
public void eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Description copied from interface:Handler
Gets called if aEvent
was emitted.- Specified by:
eventTriggered
in interfaceHandler
- Overrides:
eventTriggered
in classSimpleDuplexHandler<AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite>,SerializedApplicationMessage,Address>
- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
matchedWrite
protected void matchedWrite(HandlerContext ctx, Address recipient, SerializedApplicationMessage msg, CompletableFuture<Void> future)
Description copied from class:SimpleDuplexEventAwareHandler
Is called for each message of typeSimpleDuplexEventAwareHandler
.- Specified by:
matchedWrite
in classSimpleDuplexEventAwareHandler<AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite>,Event,SerializedApplicationMessage,Address>
- Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-
matchedRead
protected void matchedRead(HandlerContext ctx, Address sender, AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite> envelope, CompletableFuture<Void> future)
Description copied from class:SimpleInboundEventAwareHandler
Is called for each message of typeSimpleInboundEventAwareHandler
.- Specified by:
matchedRead
in classSimpleInboundEventAwareHandler<AddressedIntermediateEnvelope<? extends com.google.protobuf.MessageLite>,Event,Address>
- Parameters:
ctx
- handler contextsender
- the sender of the messageenvelope
- the messagefuture
- the future of the message
-
-