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

    Class Client

    Client is a normal client that can communicate with the server. It has documents and sends changes of the documents in local to the server to synchronize with other replicas in remote.

    Index

    Constructors

    Methods

    • activate activates this client. That is, it registers itself to the server and receives a unique ID from the server. The given ID is used to distinguish different clients.

      Returns Promise<void>

    • broadcast broadcasts the given payload to the given topic.

      Parameters

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

      Returns Promise<void>

    • deactivate deactivates this client.

      Parameters

      • options: DeactivateOptions = ...

        If keepalive is true, the client will request deactivation immediately using fetch with the keepalive option enabled. This is useful for ensuring the deactivation request completes even if the page is being unloaded, such as in beforeunload or unload event listeners. If synchronous is true, the server will wait for all pending operations to complete before deactivating.

      Returns Promise<void>

    • getActorID returns the actor stamped into this client's document changes. On a server that supports stable actors it is the stable actor derived from the project and client key (ActivateClientResponse.actorId); otherwise it falls back to the per-session id. This is the actor a version vector is keyed by, so tests and callers that reason about change authorship or GC must use this, not getID.

      Returns string | undefined

    • getID returns the per-session id of this client. It is the wire clientId used for RPC routing, not the actor stamped into document changes. Use getActorID for the change author.

      Returns string | undefined

    • has checks if the given resource is attached to this client.

      Parameters

      • key: string

        the key of the resource.

      Returns boolean

      true if the resource is attached to this client.

    • peekChannel reads the current session count of a channel without creating a session on the server. Use this when the caller only needs to display the count (e.g. "N people writing") without contributing to it and without receiving broadcasts.

      Unlike attach({ readOnly: true }), this does not occupy a Session entry on the server, does not generate heartbeat RPCs, and does not subscribe to channel events. Polling is the caller's responsibility.

      Parameters

      • channelKey: string

      Returns Promise<number>