public class BlaubotConnectionManager
extends java.lang.Object
IBlaubotDevice
instances.Modifier and Type | Field and Description |
---|---|
static int |
AUTO_MAX_RETRIES
Can be used in conjunction with connectToDevice(IBlaubotDevice, int) to let the ConnectionManager
decide how much retries to use.
|
Constructor and Description |
---|
BlaubotConnectionManager(java.util.List<IBlaubotConnectionAcceptor> acceptors,
java.util.List<IBlaubotConnector> connectors)
Creates a new
BlaubotConnectionManager instance managing the given acceptors and connectors for incoming
and outgoing connections. |
Modifier and Type | Method and Description |
---|---|
protected void |
addConnection(IBlaubotConnection connection) |
void |
addConnectionListener(IBlaubotConnectionManagerListener listener) |
IBlaubotConnection |
connectToBlaubotDevice(IBlaubotDevice device,
int maxRetries)
Tries to connect to the given
IBlaubotDevice . |
IBlaubotConnection |
connectToBlaubotDevice(java.lang.String uniqueId,
int maxRetries)
Tries to connect to the
IBlaubotDevice corresponding to the given uniqueId
by aksing all connectors if for a device object belonging to this uniqueId and trying
to connect to this device. |
IBlaubotDevice |
createBlaubotDeviceFromUniqueId(java.lang.String uniqueDeviceId)
Goes through all connected devices and tries to find an IBlaubotDevice instance with this uniqueId.
|
java.util.List<IBlaubotConnection> |
getAllConnections() |
java.util.List<IBlaubotDevice> |
getConnectedDevices() |
java.util.List<IBlaubotConnector> |
getConnectionConnectors() |
java.util.List<IBlaubotConnection> |
getConnections(IBlaubotDevice blauBotDevice) |
IBlaubotConnector |
getConnectorForDevice(java.lang.String uniqueDeviceId)
Tries to find a connector for the given uniqueDeviceId by determinig the appropriate connectors
via the IBlaubotBeaconStores meta data (if a beaconstore was provided).
|
protected void |
removeConnection(IBlaubotConnection connection) |
void |
removeConnectionListener(IBlaubotConnectionManagerListener listener) |
void |
setBeaconStore(IBlaubotBeaconStore beaconStore)
Sets the beacon store to be used to get the last beacon states and connectivity meta data
|
public static final int AUTO_MAX_RETRIES
public BlaubotConnectionManager(java.util.List<IBlaubotConnectionAcceptor> acceptors, java.util.List<IBlaubotConnector> connectors)
BlaubotConnectionManager
instance managing the given acceptors and connectors for incoming
and outgoing connections.acceptors
- the acceptors to handleconnectors
- the connectors to be used to connect to other devicesprotected void addConnection(IBlaubotConnection connection)
protected void removeConnection(IBlaubotConnection connection)
public java.util.List<IBlaubotConnection> getConnections(IBlaubotDevice blauBotDevice)
blauBotDevice
- the list of IBlaubotDevice
s of this device.public java.util.List<IBlaubotDevice> getConnectedDevices()
public java.util.List<IBlaubotConnection> getAllConnections()
public void addConnectionListener(IBlaubotConnectionManagerListener listener)
public void removeConnectionListener(IBlaubotConnectionManagerListener listener)
public java.util.List<IBlaubotConnector> getConnectionConnectors()
public IBlaubotConnector getConnectorForDevice(java.lang.String uniqueDeviceId)
uniqueDeviceId
- the unique device id to connect topublic IBlaubotConnection connectToBlaubotDevice(IBlaubotDevice device, int maxRetries)
IBlaubotDevice
.
If not successful after maxRetries, null will be returned.
The retry mechanism uses the exponential backoff method which
waiting time is configured by the BlaubotAdapterConfig
for this device's adapter.device
- the IBlaubotDevice
to connect tomaxRetries
- max number of retries or BlaubotConnectionManager.AUTO_MAX_RETRIES to let the manager decideIBlaubotConnection
or null, if no connection could be established after maxRetriespublic IBlaubotConnection connectToBlaubotDevice(java.lang.String uniqueId, int maxRetries)
IBlaubotDevice
corresponding to the given uniqueId
by aksing all connectors if for a device object belonging to this uniqueId and trying
to connect to this device.
If not successful after maxRetries, null will be returned.
The retry mechanism uses the exponential backoff method which
waiting time is configured by the BlaubotAdapterConfig
for this device's adapter.uniqueId
- the device's uniqueIdmaxRetries
- max number of retries or BlaubotConnectionManager.AUTO_MAX_RETRIES to let the manager decideIBlaubotConnection
or null, if no connection could be established after maxRetriespublic IBlaubotDevice createBlaubotDeviceFromUniqueId(java.lang.String uniqueDeviceId)
uniqueDeviceId
- the unique device id to create a blaubot device forIBlaubotDevice
instancepublic void setBeaconStore(IBlaubotBeaconStore beaconStore)
beaconStore
- the store instance