Presence represents a lightweight presence counter for tracking online users. It provides real-time count updates through the watch stream. It implements Attachable interface to be managed by Attachment.

Implements

Constructors

Properties

actorID?: string
count: number
eventStream: Observable<PresenceEvent>
eventStreamObserver: Observer<PresenceEvent>
key: string
presenceID?: string
seq: number

Methods

  • getActorID returns the actor ID of this presence counter.

    Returns undefined | string

  • getKey returns the key of this presence counter.

    Returns string

  • getPresenceID returns the presence ID from the server.

    Returns undefined | string

  • hasLocalChanges returns whether this presence has local changes or not. Presence is server-managed, so it always returns false.

    Returns boolean

  • isAttached returns whether this presence counter is attached or not.

    Returns boolean

  • publish publishes an event to all registered handlers.

    Parameters

    Returns void

  • setActor sets the actor ID into this presence counter.

    Parameters

    • actorID: string

    Returns void

  • setPresenceID sets the presence ID from the server.

    Parameters

    • presenceID: string

    Returns void

  • subscribe registers an observer for presence events. Returns an unsubscribe function.

    Parameters

    • observer: ((event) => void)

    Returns Unsubscribe

  • updateCount updates the count and sequence number if the sequence is newer. Returns true if the count was updated, false if the update was ignored.

    Parameters

    • count: number
    • seq: number

    Returns boolean