buzzk 1.9.12 → 1.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chat.js +23 -5
- package/package.json +1 -1
package/lib/chat.js
CHANGED
|
@@ -74,7 +74,9 @@ class chzzkChat {
|
|
|
74
74
|
//Load Balancing
|
|
75
75
|
|
|
76
76
|
//Connect Web Socket
|
|
77
|
-
this.#ws = new WebSocket("wss://kr-ss" + this.#ssID + ".chat.naver.com/chat"
|
|
77
|
+
this.#ws = new WebSocket("wss://kr-ss" + this.#ssID + ".chat.naver.com/chat", {
|
|
78
|
+
handshakeTimeout: 60000
|
|
79
|
+
});
|
|
78
80
|
this.#status.wsID++;
|
|
79
81
|
//Connect Web Socket
|
|
80
82
|
|
|
@@ -94,6 +96,14 @@ class chzzkChat {
|
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
|
|
99
|
+
getwsID() {
|
|
100
|
+
return this.#status.wsID;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getwsStatus() {
|
|
104
|
+
return this.#status.ws;
|
|
105
|
+
}
|
|
106
|
+
|
|
97
107
|
#openHandler(wsID) {
|
|
98
108
|
return new Promise(async (resolve, reject) => {
|
|
99
109
|
this.#ws.on("open", () => {
|
|
@@ -234,7 +244,13 @@ class chzzkChat {
|
|
|
234
244
|
"tid": 3
|
|
235
245
|
};
|
|
236
246
|
|
|
237
|
-
|
|
247
|
+
try {
|
|
248
|
+
this.#ws.send(JSON.stringify(sendOpt));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
catch (error) {
|
|
252
|
+
return resolve(false);
|
|
253
|
+
}
|
|
238
254
|
|
|
239
255
|
return resolve(true);
|
|
240
256
|
//WS Send
|
|
@@ -559,7 +575,7 @@ class chzzkChat {
|
|
|
559
575
|
}
|
|
560
576
|
//Get ChatID
|
|
561
577
|
|
|
562
|
-
let interval = 30000;
|
|
578
|
+
let interval = Math.floor(Math.random() * 20000) + 30000;
|
|
563
579
|
|
|
564
580
|
setTimeout(() => {
|
|
565
581
|
return this.#polling();
|
|
@@ -570,6 +586,8 @@ class chzzkChat {
|
|
|
570
586
|
if (!this.#status.ws) return this.#status.ping = false;
|
|
571
587
|
if (!this.#status.ping || pingID != this.#status.pingID) return;
|
|
572
588
|
|
|
589
|
+
let interval = Math.floor(Math.random() * 20000) + 30000;
|
|
590
|
+
|
|
573
591
|
let pingOpt = {
|
|
574
592
|
"ver": "3",
|
|
575
593
|
"cmd": 0
|
|
@@ -580,12 +598,12 @@ class chzzkChat {
|
|
|
580
598
|
catch (error) {
|
|
581
599
|
return setTimeout(async () => {
|
|
582
600
|
return this.#ping(pingID);
|
|
583
|
-
}, 30000);
|
|
601
|
+
}, Math.floor(Math.random() * 20000) + 30000);
|
|
584
602
|
}
|
|
585
603
|
|
|
586
604
|
setTimeout(() => {
|
|
587
605
|
return this.#ping(pingID);
|
|
588
|
-
},
|
|
606
|
+
}, interval);
|
|
589
607
|
}
|
|
590
608
|
}
|
|
591
609
|
|