buzzk 2.2.1 → 2.2.2

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.
Files changed (2) hide show
  1. package/lib/chat.js +9 -2
  2. package/package.json +1 -1
package/lib/chat.js CHANGED
@@ -47,7 +47,8 @@ class chzzkChat {
47
47
 
48
48
  #status = {
49
49
  ws: false,
50
- established: false
50
+ established: false,
51
+ reconnect: true
51
52
  }
52
53
  //Private
53
54
 
@@ -60,6 +61,8 @@ class chzzkChat {
60
61
  if (this.#status.ws) return resolve(false);
61
62
  this.#status.ws = true;
62
63
 
64
+ this.#status.reconnect = true;
65
+
63
66
  let channel = await oauth.resolve(this.accessToken);
64
67
  if (!channel) {
65
68
  this.#status.ws = false;
@@ -135,11 +138,14 @@ class chzzkChat {
135
138
  });
136
139
 
137
140
  this.#ws.on("disconnect", (data) => {
141
+ if (this.#callbacks.disconnect) this.#callbacks.disconnect(data);
142
+
143
+ if (!this.#status.reconnect) return;
144
+
138
145
  console.log("[WS] Disconnected! (" + data + ")");
139
146
 
140
147
  this.#status.ws = false;
141
148
  this.#status.established = false;
142
- if (this.#callbacks.disconnect) this.#callbacks.disconnect(data);
143
149
 
144
150
  if (this.#ws) this.#ws.off();
145
151
  if (!this.#status.established) resolve(null);
@@ -280,6 +286,7 @@ class chzzkChat {
280
286
  async disconnect() {
281
287
  return new Promise(async (resolve, reject) => {
282
288
  if (!this.#status.ws) return resolve(null);
289
+ this.#status.reconnect = false;
283
290
 
284
291
  await this.#ws.off();
285
292
  await this.#ws.close();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "2.2.1",
4
+ "version": "2.2.2",
5
5
  "description": "뿌지직 (BUZZK) - 치지직(CHZZK) 챗봇을 더욱 쉽게 개발할 수 있도록 돕는 비공식 라이브러리.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",