buzzk 1.4.0 โ†’ 1.5.1

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 CHANGED
@@ -17,27 +17,20 @@
17
17
 
18
18
  ## ๐Ÿ“– ์—…๋ฐ์ดํŠธ ๋‚ด์—ญ
19
19
 
20
- - onDisconnect ํ•จ์ˆ˜ ์ถ”๊ฐ€
21
- - ์ฑ„ํŒ…์— ์—ฐ๊ฒฐํ•˜์ง€ ๋ชปํ–ˆ๋˜ ๋ฌธ์ œ ํ•ด๊ฒฐ (UID๋ฅผ ์ œ๊ฑธ๋กœ ํ•ด๋†จ๋˜... ๋น™๊ตฌ...)
20
+ - live.getDetail ํ•จ์ˆ˜์˜ Return ๊ฐ’์— category ํ•ญ๋ชฉ ์ถ”๊ฐ€
22
21
 
23
22
  >
24
23
 
25
- - ํ•จ์ˆ˜ ์ด๋ฆ„ ์ˆ˜์ •
26
-
27
- **ํ•˜๋‹จ์˜ 1.3.0 ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ ์ฐธ๊ณ **
24
+ - ์ฑ„ํŒ…์ฐฝ ์—ฐ๊ฒฐ์ด ๋Š๊ธฐ๋˜ ๋ฌธ์ œ ํ•ด๊ฒฐ (Ping ์ถ”๊ฐ€)
25
+ - ์ฑ„ํŒ…์ฐฝ ID ๋ณ€๊ฒฝ ์‹œ ์žฌ์—ฐ๊ฒฐ ๊ตฌํ˜„
28
26
 
29
- - channelID๋กœ ์ฑ„๋„ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ ํ•จ์ˆ˜ ์ถ”๊ฐ€
30
- - ws ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ข…์†์„ฑ ์ถ”๊ฐ€
27
+ >
31
28
 
32
- >
29
+ - onDisconnect ํ•จ์ˆ˜ ์ถ”๊ฐ€
30
+ - ์ฑ„ํŒ…์— ์—ฐ๊ฒฐํ•˜์ง€ ๋ชปํ–ˆ๋˜ ๋ฌธ์ œ ํ•ด๊ฒฐ (UID๋ฅผ ์ œ๊ฑธ๋กœ ํ•ด๋†จ๋˜... ๋น™๊ตฌ...)
31
+ - ํ•จ์ˆ˜ ์ด๋ฆ„ ์ˆ˜์ •
33
32
 
34
- - ์ž๋™์™„์„ฑ ๊ธฐ๋Šฅ ์ง€์›
35
- - ํŒ”๋กœ์šฐ / ์–ธํŒ”๋กœ์šฐ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
36
- - live.getLiveDetail์˜ Return ๊ฐ’์— chatLimit ์ถ”๊ฐ€ (ํŒ”๋กœ์šฐ ๋Œ€์ƒ ์ฑ„ํŒ… ๋“ฑ...)
37
- - ํด๋ง ํ•จ์ˆ˜ ์ถ”๊ฐ€ (chatID ๋ณ€๊ฒฝ ๊ฐ์ง€)
38
- - API ํ˜ธ์ถœ ์‹คํŒจ ์‹œ ์˜ค๋ฅ˜ ํ•ธ๋“ค๋ง (Return true / null)
39
- - chat.disconnect ํ•จ์ˆ˜ ๋ณด์™„
40
- - ๋ฒ„์ „ ์ฒดํฌ ํ•จ์ˆ˜ ์ถ”๊ฐ€
33
+ **ํ•˜๋‹จ์˜ 1.3.0 ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ ์ฐธ๊ณ **
41
34
 
42
35
  ## โœ’๏ธ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ (v.1.3.0)
43
36
 
@@ -138,10 +131,7 @@
138
131
  });
139
132
 
140
133
  chat.onDisconnect(async () => { //์ฑ„ํŒ…์ฐฝ ์—ฐ๊ฒฐ์ด ๋Š๊ฒผ์„ ๋•Œ
141
- console.log("Reconnect...");
142
- chat = new buzzkChat(channel.channelID);
143
- await chat.connect();
144
- //๋‹ค์‹œ ์ƒ์„ฑ ํ›„ ์—ฐ๊ฒฐ or liveStatus ํ™•์ธ ํ›„ ๋ฐฉ์†ก์ค‘์ด๋ฉด ์—ฐ๊ฒฐ
134
+ //TODO
145
135
  });
146
136
 
147
137
  }
@@ -226,6 +216,7 @@ dotenv์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๋งค์šฐ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
226
216
  - now
227
217
  - total
228
218
  - title
219
+ - category
229
220
  - startOn
230
221
  - closeOn
231
222
  - status
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) resolve(true);
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
@@ -296,12 +300,40 @@ class chzzkChat {
296
300
 
297
301
  //Get ChatID
298
302
  let cidRes = await getStatus(this.channelID);
299
- this.#chatID = cidRes.chatID;
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
+ }
300
313
  //Get ChatID
301
314
 
315
+ let interval;
316
+ if (cidRes.polling && cidRes.polling.callPeriodMilliSecond) interval = cidRes.polling.callPeriodMilliSecond;
317
+ else interval = 10000;
318
+
302
319
  setTimeout(() => {
303
320
  return this.#polling();
304
- }, cidRes.polling.callPeriodMilliSecond);
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);
305
337
  }
306
338
  }
307
339
 
package/lib/live.js CHANGED
@@ -8,6 +8,7 @@ const { reqChzzk } = require("./tool.js");
8
8
  * @property {string} chatLimit
9
9
  * @property {userCount} userCount
10
10
  * @property {string} title
11
+ * @property {string} category
11
12
  * @property {string} startOn
12
13
  * @property {string} closeOn
13
14
  * @property {string} status
@@ -45,6 +46,7 @@ async function getDetail (channelID) {
45
46
  chatLimit: res.chatAvailableGroup,
46
47
  userCount: { now: res.concurrentUserCount, total: res.accumulateCount },
47
48
  title: res.liveTitle,
49
+ category: res.liveCategoryValue,
48
50
  startOn: res.openDate,
49
51
  closeOn: res.closeDate,
50
52
  status: res.status,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "1.4.0",
4
+ "version": "1.5.1",
5
5
  "description": "๋ฟŒ์ง€์ง (BUZZK) - ์น˜์ง€์ง(CHZZK) ์ฑ—๋ด‡์„ ๋”์šฑ ์‰ฝ๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š” ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",