@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>

    • detachChannel detaches the given channel from this client. It tells the server that this client will no longer track the channel.

      Parameters

      Returns Promise<Channel>

    • getID returns a ActorID of client.

      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.

    • isActive checks if the client is active.

      Returns boolean

    • 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>

    • restoreRevision restores the document to the given revision.

      Type Parameters

      Parameters

      Returns Promise<void>

    • sync pushes local changes of the attached documents to the server and receives changes of the remote replica from the server then apply them to local documents.

      For Channel in manual mode, it refreshes the TTL by sending a heartbeat.

      Type Parameters

      Parameters

      Returns Promise<Document<R, P>[]>

    • sync refreshes the TTL of the given channel by sending a heartbeat. This is used for manual mode channel.

      Parameters

      Returns Promise<Channel>