public class Blaubot
extends java.lang.Object
implements java.io.Closeable
BlaubotConnectionManager
, ConnectionStateMachine
,
BlaubotChannelManager
and a bunch of IBlaubotAdapter
s.
The BlaubotConnectionManager
takes IBlaubotConnection
s that
are established by the IBlaubotAdapter
implementations which receive
incoming connections (IBlaubotConnectionAcceptor
) and create
connections (IBlaubotConnector
).
The ConnectionStateMachine
manages the IBlaubotState
s by
receiving AbstractBlaubotStateMachineEvent
s created from incoming
admin BlaubotMessage
s (from IBlaubotConnection
s),
AbstractBlaubotDeviceDiscoveryEvent
(from
IBlaubotBeacon
s) as well as new or closed connections (via
IBlaubotConnectionManagerListener
s and their events).
Based on the ConnectionStateMachine
s state changes, the
BlaubotChannelManager
will be set up to act as a Master or a Slave, reset
it's context or stop/start it's services.
IBlaubotChannel
s for communication a user can use
the createChannel(short)
method. Developers
should attach ILifecycleListener
s to the Blaubot
instance to
get high level information events about the currently formed Blaubot
network (Joins/Leaves of devices, established or broken networks, ...)Constructor and Description |
---|
Blaubot(IBlaubotDevice ownDevice,
BlaubotUUIDSet uuidSet,
java.util.List<IBlaubotAdapter> adapters,
java.util.List<IBlaubotBeacon> beacons)
Creates a blaubot instance upon the given adapters and beacons.
|
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(ILifecycleListener lifecycleListener)
Adds an
ILifecycleListener to this Blaubot instance. |
void |
close() |
IBlaubotChannel |
createChannel(short channelId)
Creates the channel with the given id.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<IBlaubotAdapter> |
getAdapters() |
BlaubotChannelManager |
getChannelManager() |
BlaubotConnectionManager |
getConnectionManager() |
ConnectionStateMachine |
getConnectionStateMachine() |
IBlaubotDevice |
getOwnDevice()
The device object identifying this blaubot instance.
|
ServerConnectionManager |
getServerConnectionManager()
The server connection managing connections to a server that are created from the ServerConnector
of this blaubot instance or another blaubot instance from a connected network.
|
BlaubotServerConnector |
getServerConnector()
The attached server connector
|
BlaubotUUIDSet |
getUuidSet()
The uuid set created upon the app uuid.
|
int |
hashCode() |
boolean |
isStarted() |
void |
removeLifecycleListener(ILifecycleListener lifecycleListener)
Removes an
ILifecycleListener from this Blaubot instance. |
void |
setServerConnector(BlaubotServerConnector serverConnector)
Sets the server connector to be used.
|
void |
startBlaubot()
Starts blaubot.
|
void |
stopBlaubot()
Stops blaubot
|
java.lang.String |
toString() |
public Blaubot(IBlaubotDevice ownDevice, BlaubotUUIDSet uuidSet, java.util.List<IBlaubotAdapter> adapters, java.util.List<IBlaubotBeacon> beacons)
ownDevice
- the own device with the unique device id for this instanceuuidSet
- the uuid set containing the beacon and app uuidadapters
- the adapters to be used (currently limited to 1)beacons
- the beacons to be usedpublic void setServerConnector(BlaubotServerConnector serverConnector)
serverConnector
- the server connectorpublic BlaubotServerConnector getServerConnector()
public IBlaubotDevice getOwnDevice()
public void startBlaubot()
public void stopBlaubot()
public BlaubotConnectionManager getConnectionManager()
public ConnectionStateMachine getConnectionStateMachine()
public boolean isStarted()
public BlaubotChannelManager getChannelManager()
public java.util.List<IBlaubotAdapter> getAdapters()
public IBlaubotChannel createChannel(short channelId)
channelId
- the channel's idpublic void addLifecycleListener(ILifecycleListener lifecycleListener)
ILifecycleListener
to this Blaubot
instance.lifecycleListener
- the listener to addpublic void removeLifecycleListener(ILifecycleListener lifecycleListener)
ILifecycleListener
from this Blaubot
instance.lifecycleListener
- the listener to removepublic java.lang.String toString()
toString
in class java.lang.Object
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public BlaubotUUIDSet getUuidSet()
public ServerConnectionManager getServerConnectionManager()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object