public class LifeCycleEventDispatcher extends java.lang.Object implements IBlaubotAdminMessageListener, IBlaubotConnectionStateMachineListener
CensusMessages, calculates the diff (left or joined
 devices and prince changes) and communicates them through the ILifecycleListeners attached to this Blaubot instance.
 If attached to a ConnectionStateMachine, dispatches the corresponding
 events to it's listeners when a kingdom merge takes place, the king dies, the prince takes over and so on.| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
LOG_TAG  | 
| Constructor and Description | 
|---|
LifeCycleEventDispatcher(IBlaubotDevice ownDevice)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addLifecycleListener(ILifecycleListener lifecycleListener)
Adds an  
ILifecycleListener | 
void | 
notifyConnectedToNetwork()
Simply calls onConnected() on all registered listeners 
 | 
void | 
notifyDisconnectedFromNetwork(java.lang.String oldKingUniqueId)
Triggers onDeviceLeft(..) for all of the known devices from the old
 network (except the own devices) followed by a onDisconnected() on
 the  
ILifecycleListener added to this Blaubot
 instance. | 
void | 
onAdminMessage(AbstractAdminMessage adminMessage)
Called when an admin message was received 
 | 
void | 
onStateChanged(IBlaubotState oldState,
              IBlaubotState newState)
Gets called when the  
ConnectionStateMachine's state changed to state. | 
void | 
onStateMachineStarted()
Gets called when the  
ConnectionStateMachine changes it's IBlaubotState
 from the StoppedState to another IBlaubotState. | 
void | 
onStateMachineStopped()
Gets called when the  
ConnectionStateMachine stopped. | 
void | 
removeLifecycleListener(ILifecycleListener lifecycleListener)
Removes an  
ILifecycleListener | 
public static final java.lang.String LOG_TAG
public LifeCycleEventDispatcher(IBlaubotDevice ownDevice)
public void onAdminMessage(AbstractAdminMessage adminMessage)
IBlaubotAdminMessageListeneronAdminMessage in interface IBlaubotAdminMessageListeneradminMessage - the received admin messagepublic void onStateChanged(IBlaubotState oldState, IBlaubotState newState)
IBlaubotConnectionStateMachineListenerConnectionStateMachine's state changed to state.onStateChanged in interface IBlaubotConnectionStateMachineListeneroldState - the former state (can be null)newState - the new statepublic void notifyConnectedToNetwork()
public void notifyDisconnectedFromNetwork(java.lang.String oldKingUniqueId)
ILifecycleListener added to this Blaubot
 instance.oldKingUniqueId - the uniqueDeviceId of the former network's king device.public void onStateMachineStopped()
IBlaubotConnectionStateMachineListenerConnectionStateMachine stopped.
 This means a state change to StoppedState and is a shorthand for
 public void onStateChange(IBlaubotState state) {
     if(state instanceof StoppedState) {
         // code
     }
 }onStateMachineStopped in interface IBlaubotConnectionStateMachineListenerpublic void onStateMachineStarted()
IBlaubotConnectionStateMachineListenerConnectionStateMachine changes it's IBlaubotState
 from the StoppedState to another IBlaubotState.onStateMachineStarted in interface IBlaubotConnectionStateMachineListenerpublic void addLifecycleListener(ILifecycleListener lifecycleListener)
ILifecycleListenerlifecycleListener - the listener to addpublic void removeLifecycleListener(ILifecycleListener lifecycleListener)
ILifecycleListenerlifecycleListener - the listener to remove