Class BaseRealtime

A client that extends the functionality of BaseRest and provides additional realtime-specific features.

BaseRealtime is the equivalent, in the modular variant of the Ably Client Library SDK, of the Realtime class in the default variant of the SDK. The difference is that its constructor allows you to decide exactly which functionality the client should include. This allows unused functionality to be tree-shaken, reducing bundle size.

Note

In order to further reduce bundle size, BaseRealtime performs less logging than the Realtime class exported by the default variant of the SDK. It only logs:

  • messages that have a logLevel of 1 (that is, errors)
  • a small number of other network events

If you need more verbose logging, use the default variant of the SDK.

Hierarchy

  • BaseRealtime

Implements

Constructors

Properties

auth: Auth

An Auth object.

A Channels object.

clientId: string

A client ID, used for identifying this client when publishing messages or for presence purposes. The clientId can be any non-empty string, except it cannot contain a *. This option is primarily intended to be used in situations where the library is instantiated with a key. A clientId may also be implicit in a token used to instantiate the library; an error will be raised if a clientId specified here conflicts with the clientId implicit in the token.

connection: Connection

A Connection object.

push: Push

A Push object.

Methods

  • Makes a REST request to a provided path. This is provided as a convenience for developers who wish to use REST API functionality that is either not documented or is not yet included in the public API, without having to directly handle features such as authentication, paging, fallback hosts, MsgPack and JSON support.

    Type Parameters

    • T = any

    Parameters

    • method: string

      The request method to use, such as GET, POST.

    • path: string

      The request path.

    • version: number

      The version of the Ably REST API to use. See the REST API reference for information on versioning.

    • Optional params: any

      The parameters to include in the URL query of the request. The parameters depend on the endpoint being queried. See the REST API reference for the available parameters of each endpoint.

    • Optional body: any

      The JSON body of the request.

    • Optional headers: any

      Additional HTTP headers to include in the request.

    Returns Promise<HttpPaginatedResponse<T>>

    A promise which, upon success, will be fulfilled with the HttpPaginatedResponse response object returned by the HTTP request. This response object will contain an empty or JSON-encodable object. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.

  • Queries the REST /stats API and retrieves your application's usage statistics. Returns a PaginatedResult object, containing an array of Stats objects. See the Stats docs.

    Parameters

    • Optional params: StatsParams

      A set of parameters which are used to specify which statistics should be retrieved. If you do not provide this argument, then this method will use the default parameters described in the StatsParams interface.

    Returns Promise<PaginatedResult<Stats>>

    A promise which, upon success, will be fulfilled with a PaginatedResult object containing an array of Stats objects. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.

  • Retrieves the time from the Ably service as milliseconds since the Unix epoch. Clients that do not have access to a sufficiently well maintained time source and wish to issue Ably TokenRequests with a more accurate timestamp should use the queryTime property instead of this method.

    Returns Promise<number>

    A promise which, upon success, will be fulfilled with the time as milliseconds since the Unix epoch. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.

Generated using TypeDoc