Airgram

Guides

TdJsonClient

Component TdJsonClient is using as connector for TDLib. It's usually created internally. But if you need more control, you can create it manually.

import { Airgram, TdJsonClient } from 'airgram'

const tdJsonClient = new TdJsonClient({
  command: '/path/to/td-1.6.9/build/libtdjson'
})

// pass tdJsonClient as the first argument to Airgram constructor
const airgram = new Airgram(tdJsonClient, {
  // options
})

Constructor options:

KeyTypeNote
timeoutnumberThe maximum number of seconds allowed for the client to wait for new data.
modelsFunctionContains a function, which converts plain JSON objects to models. Details.
commandstringPath to the tdjson (windows) / libtdjson (unix) command.

Instance public API:

KeyTypeNote
catch(handler) => voidSets custom error handler for TDLib errors. Argument handler takes a function: (error: Error) => void
pause() => voidStop getting responses and updates from TDLib.
resume() => voidContinue getting responses and updates from TDLib.
destroy() => voidReset pending requests and stop receiving updates from TDLib.