@NonnullByDefault public class AbstractMessenger extends Object implements Messenger
Messenger.
Outgoing messages are passed to a BiConsumer to be passed on.
Incoming messages can be distributed using registerIncomingMessage(String, byte[]).
| Constructor and Description |
|---|
AbstractMessenger(BiConsumer<String,byte[]> outgoingMessages,
Consumer<String> notifySub,
Consumer<String> notifyUnsub)
Creates a new abstract messenger
|
| Modifier and Type | Method and Description |
|---|---|
<T> Channel<T> |
getChannel(String name,
com.google.common.reflect.TypeToken<T> type)
Gets a channel by name.
|
void |
registerIncomingMessage(String channel,
byte[] message)
Distributes an oncoming message to the channels held in this messenger.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetChannel, getConversationChannel, getConversationChannel, getReqRespChannel, getReqRespChannelpublic AbstractMessenger(BiConsumer<String,byte[]> outgoingMessages, Consumer<String> notifySub, Consumer<String> notifyUnsub)
outgoingMessages - the consumer to pass outgoing messages tonotifySub - the consumer to pass the names of channels which should be subscribed tonotifyUnsub - the consumer to pass the names of channels which should be unsubscribed frompublic void registerIncomingMessage(String channel, byte[] message)
channel - the channel the message was received onmessage - the message@Nonnull public <T> Channel<T> getChannel(@Nonnull String name, @Nonnull com.google.common.reflect.TypeToken<T> type)
MessengergetChannel in interface MessengerT - the channel message typename - the name of the channel.type - the channel message typetokenCopyright © 2022. All rights reserved.