Interface PresenceService


  • public interface PresenceService
    Service for managing tracked views of resources and querying their users.
    Since:
    8.6.0
    • Method Detail

      • getInstance

        static PresenceService getInstance()
        Returns the singleton instance of this service.
        Returns:
        The singleton instance of this service.
        Since:
        8.6.0
      • register

        void register​(@NotNull
                      @NotNull TrackingId trackingId,
                      @NotNull
                      @NotNull ResourceKey resourceKey,
                      @NotNull
                      @NotNull UserInfo user)
        Registers or refreshes one browser instance's presence for a resource.
        Parameters:
        trackingId - Identifies this specific browser instance (tab/iframe).
        resourceKey - The key of the resource being edited.
        user - The concurrent user to register.
        Since:
        8.6.0
      • heartbeat

        boolean heartbeat​(@NotNull
                          @NotNull TrackingId trackingId)
        Keeps an existing registration alive, resetting its expiry.
        Parameters:
        trackingId - Identifies the browser instance sending the heartbeat.
        Returns:
        true if the heartbeat was accepted, false if the registration was not found or has expired.
        Since:
        8.6.0
      • unregister

        void unregister​(@NotNull
                        @NotNull TrackingId trackingId)
        Removes one browser instance's registration for a resource.
        Parameters:
        trackingId - Identifies the browser instance whose registration is removed.
        Since:
        8.6.0
      • unregister

        void unregister​(@NotNull
                        @NotNull TrackingId trackingId,
                        @NotNull
                        @NotNull ResourceKey resourceKey)
        Removes one browser instance's registration for the given resource. If the resource key does not match the registration, no action is taken.
        Parameters:
        trackingId - Identifies the browser instance whose registration is removed.
        resourceKey - The key of the resource being edited.
        Since:
        8.6.0
      • getCurrentUsers

        Set<PresenceEntry> getCurrentUsers​(@NotNull
                                           @NotNull ResourceKey resourceKey)
        Returns the resource's current registrations, one entry per tracked view. Multiple entries may have the same user ID.
        Parameters:
        resourceKey - The key of the resource to look up.
        Returns:
        a detached set of registrations, or an empty set if none exist
        Since:
        8.6.0
      • getOtherUsers

        Set<PresenceEntry> getOtherUsers​(@NotNull
                                         @NotNull ResourceKey resourceKey,
                                         @NotNull
                                         @NotNull UserId userId)
        Returns one representative registration for each user on the resource, excluding the given user. The representative's tracking ID may change while the user remains present. Entries compare by resource and user ID.
        Parameters:
        resourceKey - The key of the resource to look up.
        userId - the user ID to exclude
        Returns:
        a detached set of registrations, or an empty set if none remain
        Since:
        8.6.0
      • getOtherViews

        Set<PresenceEntry> getOtherViews​(@NotNull
                                         @NotNull ResourceKey resourceKey,
                                         @NotNull
                                         @NotNull TrackingId trackingId)
        Returns the resource's current registrations excluding the given tracked view. Entries compare by resource and tracking ID.
        Parameters:
        resourceKey - The key of the resource to look up.
        trackingId - the tracking ID to exclude
        Returns:
        a detached set of registrations, or an empty set if none remain
        Since:
        8.6.0
      • getOtherMembers

        Set<PresenceEntry> getOtherMembers​(@NotNull
                                           @NotNull ResourceKey resourceKey,
                                           @NotNull
                                           @NotNull UserId userId,
                                           @NotNull
                                           @NotNull TrackingId trackingId)
        Returns other registrations according to the configured tracking strategy. User tracking excludes all views of userId, view tracking excludes only trackingId, and disabled tracking returns an empty set. User tracking returns one representative registration per other user.
        Parameters:
        resourceKey - The key of the resource to look up.
        userId - the user ID to exclude when tracking users
        trackingId - the tracking ID to exclude when tracking views
        Returns:
        a detached set of registrations, or an empty set if none remain
        Since:
        8.6.0