Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MTProtoSender

Hierarchy

  • MTProtoSender

Index

Properties

DEFAULT_OPTIONS: { logger: null; retries: number; delay: number; autoReconnect: boolean; connectTimeout: null; authKeyCallback: null; updateCallback: null; autoReconnectCallback: null; isMainSender: null; senderCallback: null; onConnectionBreak: undefined; securityChecks: boolean } = ...

Type declaration

  • logger: null
  • retries: number
  • delay: number
  • autoReconnect: boolean
  • connectTimeout: null
  • authKeyCallback: null
  • updateCallback: null
  • autoReconnectCallback: null
  • isMainSender: null
  • senderCallback: null
  • onConnectionBreak: undefined
  • securityChecks: boolean
_connection?: Connection
_updateCallback: ((client: TelegramClient, update: UpdateConnectionState) => void)

Type declaration

_userConnected: boolean
isReconnecting: boolean
_reconnecting: boolean
_disconnected: boolean
authKey: AuthKey
userDisconnected: boolean
isConnecting: boolean
_authenticated: boolean
cancellableRecvLoopPromise?: CancellablePromise<any>

Constructors

Accessors

  • get dcId(): number
  • set dcId(dcId: number): void

Methods

  • connect(connection: Connection, force: boolean): Promise<boolean>
  • isConnected(): boolean
  • _transportConnected(): undefined | boolean
  • disconnect(): Promise<void>
  • Cleanly disconnects the instance from the network, cancels all pending requests, and closes the send and receive loops.

    Returns Promise<void>

  • send(request: AnyRequest): undefined | Promise<unknown>
  • This method enqueues the given request to be sent. Its send state will be saved until a response arrives, and a Future that will be resolved when the response arrives will be returned:

    .. code-block:: javascript

    async def method():

    Sending (enqueued for the send loop)

    future = sender.send(request)

    Receiving (waits for the receive loop to read the result)

    result = await future

    Designed like this because Telegram may send the response at any point, and it can send other items while one waits for it. Once the response for this future arrives, it is set with the received result, quite similar to how a receive() call would otherwise work.

    Since the receiving part is "built in" the future, it's impossible to await receive a result that was never sent.

    Parameters

    Returns undefined | Promise<unknown>

  • _disconnect(): Promise<void>
  • _cancelLoops(): void
  • _recvLoop(): Promise<void>
  • _handleBadAuthKey(shouldSkipForMain?: boolean): void
  • _handleUpdate(message: TLMessage): Promise<void>
  • _handleAck(): void
  • reconnect(): void
  • _reconnect(): Promise<void>

Generated using TypeDoc