public class BlaubotChannelManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
subscriptionLock
Synchronizes against subscription updates and initial state transfers
|
Constructor and Description |
---|
BlaubotChannelManager(java.lang.String ownUniqueDeviceId) |
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates all MessageManagers and Channels
|
void |
addAdminMessageListener(IBlaubotAdminMessageListener adminMessageListener)
Adds a listener for admin messages.
|
void |
addConnection(IBlaubotConnection connection)
Adds a connection to be managed (receiving and sending)
|
void |
addSubscriptionListener(IBlaubotSubscriptionChangeListener subscriptionChangeListener)
Adds a subscription listener to the manager
|
int |
broadcastAdminMessage(BlaubotMessage adminMessage)
Sends a BlaubotMessage as admin message to the master, from where it is dispatched to all clients (including the master).
|
BlaubotChannelManagerInfo |
createChannelManagerInfo()
Creates an object containing detailed informations about the state of the channel manager.
|
IBlaubotChannel |
createOrGetChannel(short channelId)
Creates a channel, if not already existent.
|
void |
deactivate()
Deactivates all MessageManagers and Channels
|
protected java.lang.String |
getOwnUniqueDeviceId()
The uniqueDevice Id
|
protected boolean |
hasConnections() |
protected boolean |
isMaster() |
int |
publishChannelMessage(BlaubotMessage channelMessage)
Publishes a message posted to a channel to the master, where it is then dispatched further.
|
int |
publishToAllConnections(BlaubotMessage message)
Note: This is a low level messaging method used for internal messaging and admin messages.
|
boolean |
publishToSingleDevice(BlaubotMessage message,
java.lang.String uniqueDeviceId)
Note: This is a low level messaging method used for internal messaging and admin messages.
|
void |
removeAdminMessageListener(IBlaubotAdminMessageListener adminMessageListener)
Removes a listener for admin messages.
|
void |
removeConnection(IBlaubotConnection connection)
Removes a connection from the channel manager so it is not being managed anymore
|
void |
removeSubscriptionListener(IBlaubotSubscriptionChangeListener subscriptionChangeListener)
Removes a subscription listener from the manager
|
java.util.List<IBlaubotConnection> |
reset()
Removes all connections (and deactivates their senders/receivers).
|
void |
setMaster(boolean isMaster)
Sets this ChannelManager to master mode, meaning that this instance is managing all
communication traffic or acts in client mode.
|
protected final java.lang.Object subscriptionLock
public BlaubotChannelManager(java.lang.String ownUniqueDeviceId)
ownUniqueDeviceId
- the own unique device idpublic IBlaubotChannel createOrGetChannel(short channelId)
channelId
- the channel id to create the channel forjava.lang.IllegalArgumentException
- if the channelId is smaller than 0 or greater than 0xffffpublic void setMaster(boolean isMaster)
isMaster
- notify if the channel manager is now in master roleprotected boolean isMaster()
public void addConnection(IBlaubotConnection connection)
connection
- the connection to addpublic void removeConnection(IBlaubotConnection connection)
connection
- the connection to removeprotected java.lang.String getOwnUniqueDeviceId()
public int publishToAllConnections(BlaubotMessage message)
message
- the message that will be publishedpublic boolean publishToSingleDevice(BlaubotMessage message, java.lang.String uniqueDeviceId)
message
- the message to be sentuniqueDeviceId
- the message recipientpublic int publishChannelMessage(BlaubotMessage channelMessage)
channelMessage
- the message to be publishedpublic int broadcastAdminMessage(BlaubotMessage adminMessage)
adminMessage
- the adminMessage to be broadcastedprotected boolean hasConnections()
public void addAdminMessageListener(IBlaubotAdminMessageListener adminMessageListener)
adminMessageListener
- the listener to addpublic void removeAdminMessageListener(IBlaubotAdminMessageListener adminMessageListener)
adminMessageListener
- the listener to be removedpublic java.util.List<IBlaubotConnection> reset()
public void activate()
public void deactivate()
public BlaubotChannelManagerInfo createChannelManagerInfo()
public void addSubscriptionListener(IBlaubotSubscriptionChangeListener subscriptionChangeListener)
subscriptionChangeListener
- the listener to addpublic void removeSubscriptionListener(IBlaubotSubscriptionChangeListener subscriptionChangeListener)
subscriptionChangeListener
- the listener to remove