From f31c7deb5fec333f0066a65d37324230ce39aa34 Mon Sep 17 00:00:00 2001 From: zerodytrash <59258980+zerodytrash@users.noreply.github.com> Date: Thu, 4 Jul 2024 03:35:13 +0200 Subject: [PATCH] Fix websocket upgrade --- package.json | 2 +- src/index.js | 6 ++++-- src/proto/tiktokSchema.proto | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 32a294a..d73dac2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tiktok-live-connector", - "version": "1.1.7", + "version": "1.1.8", "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 a516ab8..2686809 100644 --- a/src/index.js +++ b/src/index.js @@ -440,11 +440,13 @@ class WebcastPushConnection extends EventEmitter { try { // Websocket specific params let wsParams = { - imprp: webcastResponse.wsParam?.value || '', - wrss: webcastResponse.wsParam?.value || '', compress: 'gzip', }; + for (let wsParam of webcastResponse.wsParams) { + wsParams[wsParam.name] = wsParam.value; + } + // Wait until ws connected, then stop request polling await this.#setupWebsocket(webcastResponse.wsUrl, wsParams); diff --git a/src/proto/tiktokSchema.proto b/src/proto/tiktokSchema.proto index 33d119f..4d9f329 100644 --- a/src/proto/tiktokSchema.proto +++ b/src/proto/tiktokSchema.proto @@ -9,7 +9,7 @@ message WebcastResponse { int64 serverTimestamp = 4; string internalExt = 5; int32 fetchType = 6; // ws (1) or polling (2) - WebsocketParam wsParam = 7; + repeated WebsocketParam wsParams = 7; int32 heartbeatDuration = 8; bool needAck = 9; string wsUrl = 10;