Interface implementing a transport to interact with Telegram servers.

interface ITelegramConnection {
    close: () => void;
    localAddress: any;
    read: (into: Uint8Array) => Promise<number>;
    remoteAddress: any;
    write: (bytes: Uint8Array) => Promise<void>;
    getMtproxyInfo(): RawInputClientProxy;
    setup(crypto: ICryptoProvider, log: Logger): void;
}

Hierarchy

  • IConnection<any, any>
    • ITelegramConnection

Properties

close: () => void

Close the underlying source.

localAddress: any

local address of the connection (if available)

read: (into: Uint8Array) => Promise<number>

Read data from the underlying source into the provided Uint8Array, up to the length of the array, and return the number of bytes read.

If there are no bytes available currently, the implementation is supposed to wait until at least one byte is available, and only then resolve the promise. Resolving the promise with a zero-length Uint8Array is marking the end of the source.

Type declaration

    • (into: Uint8Array): Promise<number>
    • Parameters

      • into: Uint8Array

      Returns Promise<number>

      Uint8Array containing the bytes that were read.

remoteAddress: any

remote address of the connection (if available)

write: (bytes: Uint8Array) => Promise<void>

Write bytes to the underlying stream, resolving once the write is complete

Methods

  • Provides crypto and logging for the transport. Not done in constructor to simplify factory.

    This method is called before any other.

    Parameters

    Returns void