buzzk 1.3.3 โ 1.5.0
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/README.md +16 -8
- package/lib/chat.js +46 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,21 +17,19 @@
|
|
|
17
17
|
|
|
18
18
|
## ๐ ์
๋ฐ์ดํธ ๋ด์ญ
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
**ํ๋จ์ 1.3.0 ๋ง์ด๊ทธ๋ ์ด์
๊ฐ์ด๋ ์ฐธ๊ณ **
|
|
20
|
+
- ์ฑํ
์ฐฝ ์ฐ๊ฒฐ์ด ๋๊ธฐ๋ ๋ฌธ์ ํด๊ฒฐ (Ping ์ถ๊ฐ)
|
|
21
|
+
- ์ฑํ
์ฐฝ ID ๋ณ๊ฒฝ ์ ์ฌ์ฐ๊ฒฐ ๊ตฌํ
|
|
23
22
|
|
|
24
|
-
>
|
|
23
|
+
>
|
|
25
24
|
|
|
25
|
+
- onDisconnect ํจ์ ์ถ๊ฐ
|
|
26
26
|
- ์ฑํ
์ ์ฐ๊ฒฐํ์ง ๋ชปํ๋ ๋ฌธ์ ํด๊ฒฐ (UID๋ฅผ ์ ๊ฑธ๋ก ํด๋จ๋... ๋น๊ตฌ...)
|
|
27
|
+
- ํจ์ ์ด๋ฆ ์์
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
**ํ๋จ์ 1.3.0 ๋ง์ด๊ทธ๋ ์ด์
๊ฐ์ด๋ ์ฐธ๊ณ **
|
|
29
30
|
|
|
30
31
|
- channelID๋ก ์ฑ๋ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ ํจ์ ์ถ๊ฐ
|
|
31
32
|
- ws ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ข
์์ฑ ์ถ๊ฐ
|
|
32
|
-
|
|
33
|
-
>
|
|
34
|
-
|
|
35
33
|
- ์๋์์ฑ ๊ธฐ๋ฅ ์ง์
|
|
36
34
|
- ํ๋ก์ฐ / ์ธํ๋ก์ฐ ๊ธฐ๋ฅ ์ถ๊ฐ
|
|
37
35
|
- live.getLiveDetail์ Return ๊ฐ์ chatLimit ์ถ๊ฐ (ํ๋ก์ฐ ๋์ ์ฑํ
๋ฑ...)
|
|
@@ -137,6 +135,10 @@
|
|
|
137
135
|
//์ฑํ
๋ณด๋ด๊ธฐ (login ํ์๋ง ๊ฐ๋ฅ)
|
|
138
136
|
}
|
|
139
137
|
});
|
|
138
|
+
|
|
139
|
+
chat.onDisconnect(async () => { //์ฑํ
์ฐฝ ์ฐ๊ฒฐ์ด ๋๊ฒผ์ ๋
|
|
140
|
+
//TODO
|
|
141
|
+
});
|
|
140
142
|
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -302,6 +304,12 @@ dotenv์ ํจ๊ป ์ฌ์ฉํ๋ ๊ฒ์ ๋งค์ฐ ๊ถ์ฅํฉ๋๋ค.
|
|
|
302
304
|
|
|
303
305
|
</details>
|
|
304
306
|
|
|
307
|
+
chat.onDisconnect(() => { //์ฑํ
์ฐฝ ์ฐ๊ฒฐ์ด ๋๊ฒผ์ ๋
|
|
308
|
+
//TODO
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
>
|
|
312
|
+
|
|
305
313
|
await chat.send("ใ
ใ
ใ
ใ
ใ
ใ
"); //์ฑํ
๋ณด๋ด๊ธฐ (login ํ์๋ง ๊ฐ๋ฅ)
|
|
306
314
|
|
|
307
315
|
>
|
package/lib/chat.js
CHANGED
|
@@ -18,6 +18,7 @@ class chzzkChat {
|
|
|
18
18
|
#chatID;
|
|
19
19
|
|
|
20
20
|
#pollingStatus = false;
|
|
21
|
+
#pingStatus = false;
|
|
21
22
|
//Private
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -106,7 +107,10 @@ class chzzkChat {
|
|
|
106
107
|
//Ping Pong
|
|
107
108
|
|
|
108
109
|
//Connected
|
|
109
|
-
else if (data.cmd == 10100)
|
|
110
|
+
else if (data.cmd == 10100) {
|
|
111
|
+
if (!this.#pingStatus) this.#ping();
|
|
112
|
+
resolve(true);
|
|
113
|
+
}
|
|
110
114
|
//Connected
|
|
111
115
|
});
|
|
112
116
|
//WS Message
|
|
@@ -208,6 +212,17 @@ class chzzkChat {
|
|
|
208
212
|
});
|
|
209
213
|
}
|
|
210
214
|
|
|
215
|
+
/**
|
|
216
|
+
* @param {function} callback
|
|
217
|
+
*/
|
|
218
|
+
onDisconnect(callback) {
|
|
219
|
+
if (!this.#ws) return callback(null);
|
|
220
|
+
|
|
221
|
+
this.#ws.on("close", () => {
|
|
222
|
+
callback();
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
/**
|
|
212
227
|
* @param {?number} size
|
|
213
228
|
* @return {Promise<chzzkMessages>}
|
|
@@ -285,12 +300,40 @@ class chzzkChat {
|
|
|
285
300
|
|
|
286
301
|
//Get ChatID
|
|
287
302
|
let cidRes = await getStatus(this.channelID);
|
|
288
|
-
|
|
303
|
+
if (cidRes.chatID && cidRes.chatID != this.#chatID) {
|
|
304
|
+
this.#chatID = cidRes.chatID;
|
|
305
|
+
|
|
306
|
+
//Reconnect
|
|
307
|
+
this.#pollingStatus = false;
|
|
308
|
+
await this.disconnect();
|
|
309
|
+
await this.connect();
|
|
310
|
+
return;
|
|
311
|
+
//Reconnect
|
|
312
|
+
}
|
|
289
313
|
//Get ChatID
|
|
290
314
|
|
|
315
|
+
let interval;
|
|
316
|
+
if (cidRes.polling && cidRes.polling.callPeriodMilliSecond) interval = cidRes.polling.callPeriodMilliSecond;
|
|
317
|
+
else interval = 10000;
|
|
318
|
+
|
|
291
319
|
setTimeout(() => {
|
|
292
320
|
return this.#polling();
|
|
293
|
-
},
|
|
321
|
+
}, interval);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async #ping () {
|
|
325
|
+
if (!this.#ws) return this.#pingStatus = false;
|
|
326
|
+
this.#pingStatus = true;
|
|
327
|
+
|
|
328
|
+
let pingOpt = {
|
|
329
|
+
"ver": "2",
|
|
330
|
+
"cmd": 0
|
|
331
|
+
};
|
|
332
|
+
this.#ws.send(JSON.stringify(pingOpt));
|
|
333
|
+
|
|
334
|
+
setTimeout(() => {
|
|
335
|
+
return this.#ping();
|
|
336
|
+
}, 20000);
|
|
294
337
|
}
|
|
295
338
|
}
|
|
296
339
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buzzk",
|
|
3
3
|
"displayName": "BUZZK",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"description": "๋ฟ์ง์ง (BUZZK) - ์น์ง์ง(CHZZK) ์ฑ๋ด์ ๋์ฑ ์ฝ๊ฒ ๊ฐ๋ฐํ ์ ์๋๋ก ๋๋ ๋น๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"type": "commonjs",
|