@yorkie-js/sdk
    Preparing search index...

    Class Channel

    Channel represents a lightweight channel for presence and messaging.

    Implements

    Index

    Constructors

    Methods

    • broadcast sends a message to all clients watching this channel.

      Parameters

      • topic: string
      • payload: any
      • Optionaloptions: BroadcastOptions

      Returns void

    • getActorID returns the actor ID of this channel.

      Returns string | undefined

    • getFirstKeyPath returns the first key path to the presence count.

      Returns string

    • getKey returns the key of this channel.

      Returns string

    • getPresenceCount returns the current count value.

      Returns number

    • getSessionID returns the session ID from the server.

      Returns string | undefined

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

      Returns boolean

    • isAttached returns whether this channel is attached or not.

      Returns boolean

    • setActor sets the actor ID into this channel.

      Parameters

      • actorID: string

      Returns void

    • setSessionID sets the session ID from the server.

      Parameters

      • sessionID: string

      Returns void

    • subscribe registers a callback to subscribe to events on the channel. The callback will be called when the broadcast event is received from the remote client.

      Parameters

      • type: "broadcast"
      • next: NextFn<BroadcastEvent>

      Returns Unsubscribe

    • subscribe registers a callback to subscribe to events on the channel. The callback will be called when the local client sends a broadcast event.

      Parameters

      • type: "local-broadcast"
      • next: NextFn<LocalBroadcastEvent>

      Returns Unsubscribe

    • subscribe registers a callback to subscribe to events on the channel. The callback will be called when an authentication error occurs.

      Parameters

      • type: "auth-error"
      • next: NextFn<AuthErrorEvent>

      Returns Unsubscribe

    • subscribe registers a callback to subscribe to presence events on the channel. The callback will be called when the presence count changes.

      Parameters

      • type: "presence"
      • next: NextFn<PresenceEvent>

      Returns Unsubscribe

    • subscribe registers a callback to subscribe to all events on the channel.

      Parameters

      Returns Unsubscribe

    • subscribe registers a callback to subscribe to broadcast events for a specific topic. The callback will be called when a broadcast event with the matching topic is received.

      Parameters

      • topic: string
      • next: NextFn<BroadcastEvent>

      Returns Unsubscribe

    • subscribe registers an observer for all channel events. Returns an unsubscribe function.

      Parameters

      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