Class PresenceManager


  • public class PresenceManager
    extends AbstractCollaborationManager
    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.
    Since:
    3.2
    Author:
    Vaadin Ltd
    • Constructor Detail

      • PresenceManager

        public PresenceManager​(Component component,
                               UserInfo localUser,
                               String topicId)
        Creates a new manager for the provided component.

        The provided user information is used to set the presence of the local user with markAsPresent(boolean) (the default is false).

        Parameters:
        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
      • PresenceManager

        public PresenceManager​(ConnectionContext context,
                               UserInfo localUser,
                               String topicId,
                               CollaborationEngine collaborationEngine)
        Creates a new manager for the provided connection context.

        The provided user information is used to set the presence of the local user with markAsPresent(boolean) (the default is false).

        Parameters:
        context - the context that manages connection status, not null
        localUser - the information of the local user, not null
        topicId - the id of the topic to connect to, not null
        collaborationEngine - the collaboration engine instance to use, not null
    • Method Detail

      • 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

        @Deprecated
        public void setNewUserHandler​(NewUserHandler handler)
        Deprecated.
        Sets a handler which will be invoked when a user becomes present.

        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.

        Parameters:
        handler - the user presence handler, or null to remove an existing handler
      • setPresenceHandler

        public void setPresenceHandler​(PresenceHandler handler)
        Sets a handler which will be invoked when a user becomes present.

        The handler accepts a PresenceHandler.PresenceContext 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.

        Parameters:
        handler - the user presence handler, or null to remove an existing handler