link
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:
Key | Type | Note |
---|---|---|
timeout | number | The maximum number of seconds allowed for the client to wait for new data. |
models | Function | Contains a function, which converts plain JSON objects to models. Details. |
command | string | Path to the tdjson (windows) / libtdjson (unix) command. |
Instance public API:
Key | Type | Note |
---|---|---|
catch | (handler) => void | Sets custom error handler for TDLib errors. Argument handler takes a function: (error: Error) => void |
pause | () => void | Stop getting responses and updates from TDLib. |
resume | () => void | Continue getting responses and updates from TDLib. |
destroy | () => void | Reset pending requests and stop receiving updates from TDLib. |