public class ChannelSubscriptionListener extends java.lang.Object implements IBlaubotAdminMessageListener, ILifecycleListener
| Modifier and Type | Class and Description |
|---|---|
static interface |
ChannelSubscriptionListener.SubscriptionChangeListener |
| Constructor and Description |
|---|
ChannelSubscriptionListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
addSubscriptionChangeListener(ChannelSubscriptionListener.SubscriptionChangeListener changeListener)
Adds a listener to be informed when the subscriptions change.
|
java.util.Set<java.lang.Short> |
getChannels()
The set of known channels that are used
|
java.util.Set<java.lang.String> |
getSubscribersOfChannel(short channelId)
creates a set of the known subscribers to a specific channel id.
|
void |
onAdminMessage(AbstractAdminMessage adminMessage)
Called when an admin message was received
|
void |
onConnected()
Triggered when the
Blaubot instance becomes part of a blaubot kingdom. |
void |
onDeviceJoined(IBlaubotDevice blaubotDevice)
Triggered when another
Blaubot instance on another IBlaubotDevice joined the network. |
void |
onDeviceLeft(IBlaubotDevice blaubotDevice)
Triggered when an
IBlaubotDevice left the blaubot kingdom. |
void |
onDisconnected()
Triggered when the
Blaubot instance is no longer part of a blaubot kingdom. |
void |
onKingDeviceChanged(IBlaubotDevice oldKing,
IBlaubotDevice newKing)
Triggered when the king device was changed.
|
void |
onPrinceDeviceChanged(IBlaubotDevice oldPrince,
IBlaubotDevice newPrince)
Triggered when a prince nomination was completed.
|
void |
removeSubscriptionChangeListener(ChannelSubscriptionListener.SubscriptionChangeListener changeListener)
Removes a formerly added listener
|
public java.util.Set<java.lang.Short> getChannels()
public java.util.Set<java.lang.String> getSubscribersOfChannel(short channelId)
channelId - the channel to retrieve the list of subscribers forpublic void onAdminMessage(AbstractAdminMessage adminMessage)
IBlaubotAdminMessageListeneronAdminMessage in interface IBlaubotAdminMessageListeneradminMessage - the received admin messagepublic void onConnected()
ILifecycleListenerBlaubot instance becomes part of a blaubot kingdom.onConnected in interface ILifecycleListenerpublic void onDisconnected()
ILifecycleListenerBlaubot instance is no longer part of a blaubot kingdom.onDisconnected in interface ILifecycleListenerpublic void onDeviceJoined(IBlaubotDevice blaubotDevice)
ILifecycleListenerBlaubot instance on another IBlaubotDevice joined the network.
It is guaranteed that for one specific IBlaubotDevice ILifecycleListener.onDeviceJoined(IBlaubotDevice)
is never called twice without a triggered ILifecycleListener.onDeviceLeft(IBlaubotDevice) in between.onDeviceJoined in interface ILifecycleListenerblaubotDevice - the joined devicepublic void onDeviceLeft(IBlaubotDevice blaubotDevice)
ILifecycleListenerIBlaubotDevice left the blaubot kingdom.onDeviceLeft in interface ILifecycleListenerblaubotDevice - the device that just leftpublic void onPrinceDeviceChanged(IBlaubotDevice oldPrince, IBlaubotDevice newPrince)
ILifecycleListeneronPrinceDeviceChanged in interface ILifecycleListeneroldPrince - the old prince (may be null, in case no prince was nominated previously)newPrince - the new prince (may be null, in case there is no device to be prince)public void onKingDeviceChanged(IBlaubotDevice oldKing, IBlaubotDevice newKing)
ILifecycleListeneronKingDeviceChanged in interface ILifecycleListeneroldKing - the old kingnewKing - the new kingpublic void addSubscriptionChangeListener(ChannelSubscriptionListener.SubscriptionChangeListener changeListener)
changeListener - the listener to be addedpublic void removeSubscriptionChangeListener(ChannelSubscriptionListener.SubscriptionChangeListener changeListener)
changeListener - the listener to be removed