public class ConnectionStateMachine
extends java.lang.Object
BlaubotConnectionManager
and the
AbstractBlaubotDeviceDiscoveryEvent
s from the beacons to the current state. The state will handle the event
based state changes by themselves (calling nextState).Modifier and Type | Field and Description |
---|---|
protected Blaubot |
blaubot |
protected IBlaubotState |
currentState |
Constructor and Description |
---|
ConnectionStateMachine(IBlaubotDevice ownDevice,
BlaubotConnectionManager connectionManager,
java.util.List<IBlaubotAdapter> adapters,
java.util.List<IBlaubotBeacon> beacons,
Blaubot blaubot,
ServerConnectionManager serverConnectionManager)
Create the connection state machine for a blaubot instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionStateMachineListener(IBlaubotConnectionStateMachineListener connectionStateMachineListener)
Registers a listener to get informed about state changes of the state machine
|
BlaubotBeaconService |
getBeaconService() |
java.util.List<IBlaubotConnectionAcceptor> |
getConnectionAcceptors() |
IBlaubotState |
getCurrentState() |
boolean |
isStateMachineStarted() |
void |
pushStateMachineEvent(AbstractBlaubotStateMachineEvent stateMachineEvent)
Pushes a AbstractBlaubotStateMachineEvent to the StateMachine's event queue.
|
void |
removeConnectionStateMachineListener(IBlaubotConnectionStateMachineListener connectionStateMachineListener)
Removes a previously added listener
|
void |
startEventDispatcher()
Starts the CSM's event dispatcher.
|
void |
startStateMachine()
Starts the state machine by pushing a start event to the CSM's event queue.
|
void |
stopEventDispatcher() |
void |
stopStateMachine()
Requests a stop of the CSM by pushing an event to the CSM's event queue.
|
protected final Blaubot blaubot
protected IBlaubotState currentState
public ConnectionStateMachine(IBlaubotDevice ownDevice, BlaubotConnectionManager connectionManager, java.util.List<IBlaubotAdapter> adapters, java.util.List<IBlaubotBeacon> beacons, Blaubot blaubot, ServerConnectionManager serverConnectionManager)
ownDevice
- the own deviceconnectionManager
- the connection manager managing the blaubot acceptorsadapters
- the adaptersbeacons
- the beacons to be usedblaubot
- the blaubot instanceserverConnectionManager
- server connection managerpublic void startEventDispatcher()
public void stopEventDispatcher()
public void startStateMachine()
public void stopStateMachine()
public void addConnectionStateMachineListener(IBlaubotConnectionStateMachineListener connectionStateMachineListener)
connectionStateMachineListener
- the listener to addpublic void removeConnectionStateMachineListener(IBlaubotConnectionStateMachineListener connectionStateMachineListener)
connectionStateMachineListener
- the listener to removepublic java.util.List<IBlaubotConnectionAcceptor> getConnectionAcceptors()
public BlaubotBeaconService getBeaconService()
public IBlaubotState getCurrentState()
public boolean isStateMachineStarted()
public void pushStateMachineEvent(AbstractBlaubotStateMachineEvent stateMachineEvent)
stateMachineEvent
- the event