public class PresenceManager extends Object
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.
|
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.
|
public PresenceManager(Component component, UserInfo localUser, String topicId)
The provided user information is used to set the presence of the local
user with markAsPresent(boolean)
(the default is false
).
component
- the component which holds UI access, not null
localUser
- the information of the local user, not null
topicId
- the id of the topic to connect to, not null
public String getTopicId()
public void close()
public void markAsPresent(boolean markAsPresent)
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.
markAsPresent
- true
to mark the user as present in the topic,
false
to set as not presentpublic void setNewUserHandler(NewUserHandler handler)
The handler accepts a UserInfo
instance as a parameter and should
return a Registration
which will be removed when the user stops
being present.
Replacing an existing handler will remove all registrations from the previous one.
handler
- the user presence handler, or null
to remove an
existing handlerCopyright © 2021. All rights reserved.