reconnecter get and set for config.

This commit is contained in:
Miroslav Šedivý 2021-07-15 20:58:21 +02:00
parent 121f3bbe29
commit a38ad13fb1

View File

@ -104,6 +104,18 @@ export class Reconnecter extends EventEmitter<ReconnecterEvents> {
return this._last_connected
}
public get config(): ReconnecterConfig {
return { ...this._config }
}
public set config(conf: ReconnecterConfig) {
this._config = { ...conf }
if (this._config.max_reconnects > this._total_reconnects) {
this.close(new Error('reconnection config changed'))
}
}
public open(): void {
if (this._open) {
throw new Error('connection is already open')