From bcaca692b9d9a478afd775e852d061076018e8aa Mon Sep 17 00:00:00 2001 From: zerodytrash <59258980+zerodytrash@users.noreply.github.com> Date: Thu, 15 Sep 2022 23:56:59 +0200 Subject: [PATCH] Fix `Already connected!` error --- package.json | 2 +- src/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fe3a6e4..6e2ba0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tiktok-live-connector", - "version": "1.0.0", + "version": "1.0.1", "description": "Node.js module to receive live stream chat events like comments and gifts from TikTok LIVE", "main": "index.js", "types": "./dist/index.d.ts", diff --git a/src/index.js b/src/index.js index 565adc6..8a9e6cd 100644 --- a/src/index.js +++ b/src/index.js @@ -159,8 +159,6 @@ class WebcastPushConnection extends EventEmitter { await this.#fetchRoomData(true); - this.#isConnected = true; - // Sometimes no upgrade to WebSocket is offered by TikTok // In that case we use request polling (if enabled and possible) if (!this.#isWsUpgradeDone) { @@ -179,6 +177,8 @@ class WebcastPushConnection extends EventEmitter { this.#startFetchRoomPolling(); } + this.#isConnected = true; + let state = this.getState(); this.emit(ControlEvents.CONNECTED, state);