From d561a6a7dee57748a867eff25f2b734e9d96a97f Mon Sep 17 00:00:00 2001 From: ThisIsEsh <13537179+ThisIsEsh@users.noreply.github.com> Date: Sun, 7 Apr 2024 07:01:53 +0300 Subject: [PATCH] Send commands based on transport state instead of connected state (#278) --- src/centrifuge.ts | 42 ++++++++++++++++-------------------------- src/subscription.ts | 33 ++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/centrifuge.ts b/src/centrifuge.ts index 5fb29e62..f25e927b 100644 --- a/src/centrifuge.ts +++ b/src/centrifuge.ts @@ -65,6 +65,7 @@ export class UnauthorizedError extends Error { /** Centrifuge is a Centrifuge/Centrifugo bidirectional client. */ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter) { state: State; + private _transportIsOpen: boolean; private _endpoint: string | Array; private _emulation: boolean; private _transports: any[]; @@ -111,6 +112,7 @@ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter, options?: Partial) { super(); this.state = State.Disconnected; + this._transportIsOpen = false; this._endpoint = endpoint; this._emulation = false; this._transports = []; @@ -762,28 +764,11 @@ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter TypedEventEmitter { + this._centrifuge._call(cmd).then(resolveCtx => { this._inflight = false; // @ts-ignore - improve later. const result = resolveCtx.reply.subscribe; @@ -492,7 +499,7 @@ export class Subscription extends (EventEmitter as new () => TypedEventEmitter