feat(core): override layer number
This commit is contained in:
parent
cb2df91187
commit
f3e7de5c8c
2 changed files with 16 additions and 1 deletions
|
@ -146,6 +146,15 @@ export namespace BaseTelegramClient {
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
niceStacks?: boolean
|
niceStacks?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* **EXPERT USE ONLY!**
|
||||||
|
*
|
||||||
|
* Override TL layer used for the connection. /;'
|
||||||
|
*
|
||||||
|
* **Does not** change the schema used.
|
||||||
|
*/
|
||||||
|
overrideLayer?: number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +216,7 @@ export class BaseTelegramClient extends EventEmitter {
|
||||||
protected _primaryDc: tl.RawDcOption
|
protected _primaryDc: tl.RawDcOption
|
||||||
|
|
||||||
private _niceStacks: boolean
|
private _niceStacks: boolean
|
||||||
|
readonly _layer: number
|
||||||
|
|
||||||
private _keepAliveInterval: NodeJS.Timeout
|
private _keepAliveInterval: NodeJS.Timeout
|
||||||
private _lastRequestTime = 0
|
private _lastRequestTime = 0
|
||||||
|
@ -265,6 +275,8 @@ export class BaseTelegramClient extends EventEmitter {
|
||||||
this._disableUpdates = opts.disableUpdates ?? false
|
this._disableUpdates = opts.disableUpdates ?? false
|
||||||
this._niceStacks = opts.niceStacks ?? true
|
this._niceStacks = opts.niceStacks ?? true
|
||||||
|
|
||||||
|
this._layer = opts.overrideLayer ?? tl.CURRENT_LAYER
|
||||||
|
|
||||||
let deviceModel = 'mtcute on '
|
let deviceModel = 'mtcute on '
|
||||||
if (typeof process !== 'undefined' && typeof require !== 'undefined') {
|
if (typeof process !== 'undefined' && typeof require !== 'undefined') {
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
@ -310,6 +322,7 @@ export class BaseTelegramClient extends EventEmitter {
|
||||||
transportFactory: this._transportFactory,
|
transportFactory: this._transportFactory,
|
||||||
dc: this._primaryDc,
|
dc: this._primaryDc,
|
||||||
reconnectionStrategy: this._reconnectionStrategy,
|
reconnectionStrategy: this._reconnectionStrategy,
|
||||||
|
layer: this._layer,
|
||||||
})
|
})
|
||||||
this.primaryConnection.on('usable', async () => {
|
this.primaryConnection.on('usable', async () => {
|
||||||
this._keepAliveInterval = setInterval(async () => {
|
this._keepAliveInterval = setInterval(async () => {
|
||||||
|
@ -654,6 +667,7 @@ export class BaseTelegramClient extends EventEmitter {
|
||||||
transportFactory: this._transportFactory,
|
transportFactory: this._transportFactory,
|
||||||
reconnectionStrategy: this._reconnectionStrategy,
|
reconnectionStrategy: this._reconnectionStrategy,
|
||||||
inactivityTimeout,
|
inactivityTimeout,
|
||||||
|
layer: this._layer,
|
||||||
})
|
})
|
||||||
|
|
||||||
connection.on('error', (err) => this._emitError(err, connection))
|
connection.on('error', (err) => this._emitError(err, connection))
|
||||||
|
|
|
@ -42,6 +42,7 @@ export interface TelegramConnectionParams extends PersistentConnectionParams {
|
||||||
initConnection: tl.RawInitConnectionRequest
|
initConnection: tl.RawInitConnectionRequest
|
||||||
inactivityTimeout?: number
|
inactivityTimeout?: number
|
||||||
niceStacks?: boolean
|
niceStacks?: boolean
|
||||||
|
layer: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageHandlers: Record<string, string /* keyof TelegramConnection */> = {
|
const messageHandlers: Record<string, string /* keyof TelegramConnection */> = {
|
||||||
|
@ -668,7 +669,7 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
debug('wrapping %s with initConnection', message._)
|
debug('wrapping %s with initConnection', message._)
|
||||||
obj = {
|
obj = {
|
||||||
_: 'invokeWithLayer',
|
_: 'invokeWithLayer',
|
||||||
layer: tl.CURRENT_LAYER,
|
layer: this.params.layer,
|
||||||
query: {
|
query: {
|
||||||
...this.params.initConnection,
|
...this.params.initConnection,
|
||||||
query: message,
|
query: message,
|
||||||
|
|
Loading…
Reference in a new issue