com.vaadin.collaborationengine.
Class PresenceManager
- java.lang.Object
-
- com.vaadin.collaborationengine.PresenceManager
-
public class PresenceManager extends Object
Manager to handle user presence in topics. It allows to set the user presence in the set topic and get a list of users currently set as present in the same topic. A handler can be set to react when the presence of a user changes.
Author:
Vaadin Ltd
-
-
Constructor Summary
Constructors Constructor and Description PresenceManager(Component component, UserInfo localUser, String topicId)
Creates a new manager for the provided component, with the provided local user and topic id.
-
Method Summary
All Methods Modifier and Type Method and Description void
close()
Disconnects from the topic.
String
getTopicId()
Gets the topic id.
void
markAsPresent(boolean markAsPresent)
Configures the manager to mark the local user present in the topic.
void
setNewUserHandler(NewUserHandler handler)
Sets a handler which will be invoked when a user becomes present.
-
-
-
Constructor Detail
-
PresenceManager
public PresenceManager(Component component, UserInfo localUser, String topicId)
Creates a new manager for the provided component, with the provided local user and topic id.
The provided user information is used to set the presence of the local user with
markAsPresent(boolean)
(the default isfalse
).Parameters:
component
- the component which holds UI access, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
-
-
Method Detail
-
getTopicId
public String getTopicId()
Gets the topic id.
Returns:
the topic id
-
close
public void close()
Disconnects from the topic.
-
markAsPresent
public void markAsPresent(boolean markAsPresent)
Configures the manager to mark the local user present in the topic.
If the user wasn't already present in the topic, all managers connected to the same topic will be notified of the change and their handlers will be applied to the user instance.
Parameters:
markAsPresent
-true
to mark the user as present in the topic,false
to set as not present
-
setNewUserHandler
public void setNewUserHandler(NewUserHandler handler)
Sets a handler which will be invoked when a user becomes present.
The handler accepts a
UserInfo
instance as a parameter and should return aRegistration
which will be removed when the user stops being present.Replacing an existing handler will remove all registrations from the previous one.
Parameters:
handler
- the user presence handler, ornull
to remove an existing handler
-
-