Basic MTProto client implementation, only doing the bare minimum to make RPC calls and receive low-level updates, as well as providing some APIs to manage that.

Constructors

Properties

_config: ConfigManager = ...
_defaultDcs: DcOptions

Primary DCs taken from MtClientOptions.defaultDcs, loaded from session or changed by other means (like redirecting).

_layer: number

TL layer used by the client

_readerMap: TlReaderMap

TL readers map used by the client

_testMode: boolean

"Test mode" taken from MtClientOptions.testMode

_writerMap: TlWriterMap

TL writers map used by the client

Crypto provider taken from MtClientOptions.crypto

log: Logger
network: NetworkManager
onConnecting: Emitter<void> = ...
onNetworkChanged: Emitter<boolean> = ...
onUpdate: Emitter<TypeUpdates> = ...
onUsable: Emitter<void> = ...
stopSignal: AbortSignal

Storage manager

Methods

  • Make an RPC call.

    The connection must have been connect-ed before calling this method.

    This method is still quite low-level and you shouldn't use this when using high-level API provided by @mtcute/client.

    Type Parameters

    • T extends RpcMethod

    Parameters

    Returns Promise<RawMt_rpc_error | RpcCallReturn[T["_"]]>

  • Close all connections and finalize the client.

    Returns Promise<void>

  • Initialize the connection to the primary DC.

    You shouldn't usually call this method directly as it is called implicitly the first time you call call.

    Returns Promise<void>

  • Parameters

    • err: unknown

    Returns void

  • Register an error handler for the client

    Parameters

    • handler: (err: unknown) => void

      Error handler.

    Returns void

  • ADVANCED

    Do all the preparations, but don't connect just yet. Useful when you want to do some preparations before connecting, like setting up session.

    Call connect to actually connect.

    Returns Promise<void>