Package org.drasyl.messenger
Class Messenger
- java.lang.Object
-
- org.drasyl.messenger.Messenger
-
public class Messenger extends Object
The Messenger is responsible for handling the outgoing message flow and sending messages to the recipient.
-
-
Constructor Summary
Constructors Constructor Description Messenger(MessageSink loopbackSink, PeersManager peersManager, PeerChannelGroup channelGroup)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.reactivex.rxjava3.core.Observable<CompressedPublicKey>
communicationOccurred()
Returns anObservable
, which emits theCompressedPublicKey
of each peer a message is sent to.CompletableFuture<Void>
send(RelayableMessage message)
Sendsmessage
to the recipient defined in the message.void
setIntraVmSink(MessageSink intraVmSink)
void
unsetIntraVmSink()
-
-
-
Constructor Detail
-
Messenger
public Messenger(MessageSink loopbackSink, PeersManager peersManager, PeerChannelGroup channelGroup)
-
-
Method Detail
-
send
public CompletableFuture<Void> send(RelayableMessage message)
Sendsmessage
to the recipient defined in the message. Throws aMessengerException
if sending is not possible (e.g. because no path to the peer exists).The method tries to choose the best path to send the message to the recipient. Thus, it first checks whether the recipient can be reached locally. Then it searches for direct connections to the recipient. If there is no direct connection, the message is relayed to the Super Peer.
- Parameters:
message
- message to be sent- Returns:
- a completed future if the message was successfully processed, otherwise an exceptionally future
-
setIntraVmSink
public void setIntraVmSink(MessageSink intraVmSink)
-
unsetIntraVmSink
public void unsetIntraVmSink()
-
communicationOccurred
public io.reactivex.rxjava3.core.Observable<CompressedPublicKey> communicationOccurred()
Returns anObservable
, which emits theCompressedPublicKey
of each peer a message is sent to.- Returns:
- an
Observable
, which emits theCompressedPublicKey
of each peer a message is sent to
-
-