douyin-danma-listener 0.2.0 → 0.2.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/lib/index.js CHANGED
@@ -51,6 +51,7 @@ class DouYinDanmaClient extends TypedEmitter {
51
51
  this.emit("error", new Error("获取抖音弹幕签名失败"));
52
52
  return;
53
53
  }
54
+ this.emit("init", url);
54
55
  const cookies = this.cookie || (await getCookie());
55
56
  this.ws = new WebSocket(url, {
56
57
  headers: {
@@ -88,7 +89,9 @@ class DouYinDanmaClient extends TypedEmitter {
88
89
  this.reconnectAttempts = this.autoReconnect;
89
90
  this.stopHeartbeat();
90
91
  this.stopTimeoutCheck();
91
- this.ws.close();
92
+ if (this.ws.readyState === WebSocket.OPEN) {
93
+ this.ws.close();
94
+ }
92
95
  }
93
96
  startHeartbeat() {
94
97
  if (this.isHeartbeatRunning) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "douyin-danma-listener",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "douyin danma listener",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./types/index.d.ts",
package/types/types.d.ts CHANGED
@@ -157,6 +157,8 @@ export interface GiftMessage {
157
157
  totalCount: string;
158
158
  clientGiftSource: number;
159
159
  sendTime: string;
160
+ // repeatEnd 表示礼物连击完毕,这个为1时,sendTime值为秒级时间戳,否则为毫秒级时间戳
161
+ repeatEnd: null | 1;
160
162
  }
161
163
 
162
164
  export interface RoomUserSeqMessage {