Class Agent<TCustom>

An Agent is the representation of a client's Connection state on the server. If the Connection was created through backend.connect (i.e. the client is running in the same Node process as the server), then the Agent associated with a Connection can be accessed through connection.agent.

The Agent will be made available in all middleware requests. The agent.custom field is an object that can be used for storing arbitrary information for use in middleware.

Type Parameters

  • TCustom = any

Constructors

Properties

backend: sharedb
clientId: string
connectTime: number
custom: TCustom

Object for custom use in middleware to store app-specific state for a given client session. It is in memory only as long as the session is active, and it is passed to each middleware call.

src: string
stream: Duplex & {
    isServer?: boolean;
}

Type declaration

  • Optional isServer?: boolean

    true if this is agent is handling a ShareDB client in the same Node process.

Methods

  • Sends a JSON-compatible message to the client for this agent.

    Parameters

    Returns void