liangzimixin 0.3.38 → 0.3.39

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/dist/index.cjs CHANGED
@@ -20305,6 +20305,8 @@ var ConnectionManager = class {
20305
20305
  options;
20306
20306
  /** 心跳定时器 */
20307
20307
  heartbeatTimer = null;
20308
+ /** pong 超时定时器 — 每次 ping 后独立计时 */
20309
+ pongTimeoutTimer = null;
20308
20310
  /** 当前重连尝试次数 */
20309
20311
  reconnectAttempts = 0;
20310
20312
  /** 是否处于运行状态 */
@@ -20372,6 +20374,7 @@ var ConnectionManager = class {
20372
20374
  });
20373
20375
  this.client.on("pong", () => {
20374
20376
  this.pongReceived = true;
20377
+ this.clearPongTimeout();
20375
20378
  log22.info("heartbeat: pong received");
20376
20379
  });
20377
20380
  }
@@ -20394,14 +20397,30 @@ var ConnectionManager = class {
20394
20397
  this.pongReceived = false;
20395
20398
  this.client.ping();
20396
20399
  log22.info("heartbeat: ping sent");
20400
+ this.clearPongTimeout();
20401
+ this.pongTimeoutTimer = setTimeout(() => {
20402
+ if (!this.pongReceived && this.running) {
20403
+ log22.warn("heartbeat: pong timeout (independent timer), closing connection");
20404
+ this.client.close(4e3, "pong timeout");
20405
+ this.scheduleReconnect();
20406
+ }
20407
+ }, this.options.heartbeatTimeoutMs);
20397
20408
  }, this.options.heartbeatIntervalMs);
20398
20409
  }
20410
+ /** 清除 pong 超时定时器 */
20411
+ clearPongTimeout() {
20412
+ if (this.pongTimeoutTimer) {
20413
+ clearTimeout(this.pongTimeoutTimer);
20414
+ this.pongTimeoutTimer = null;
20415
+ }
20416
+ }
20399
20417
  /** 停止心跳定时器 */
20400
20418
  stopHeartbeat() {
20401
20419
  if (this.heartbeatTimer) {
20402
20420
  clearInterval(this.heartbeatTimer);
20403
20421
  this.heartbeatTimer = null;
20404
20422
  }
20423
+ this.clearPongTimeout();
20405
20424
  }
20406
20425
  /** 调度重连 (防止并发重连) */
20407
20426
  scheduleReconnect() {
package/dist/index.d.cts CHANGED
@@ -855,6 +855,8 @@ declare class ConnectionManager {
855
855
  private readonly options;
856
856
  /** 心跳定时器 */
857
857
  private heartbeatTimer;
858
+ /** pong 超时定时器 — 每次 ping 后独立计时 */
859
+ private pongTimeoutTimer;
858
860
  /** 当前重连尝试次数 */
859
861
  private reconnectAttempts;
860
862
  /** 是否处于运行状态 */
@@ -881,6 +883,8 @@ declare class ConnectionManager {
881
883
  private registerEvents;
882
884
  /** 启动心跳保活 — 定时发送 WebSocket Ping 帧 */
883
885
  private startHeartbeat;
886
+ /** 清除 pong 超时定时器 */
887
+ private clearPongTimeout;
884
888
  /** 停止心跳定时器 */
885
889
  private stopHeartbeat;
886
890
  /** 调度重连 (防止并发重连) */
@@ -19364,6 +19364,8 @@ var ConnectionManager = class {
19364
19364
  options;
19365
19365
  /** 心跳定时器 */
19366
19366
  heartbeatTimer = null;
19367
+ /** pong 超时定时器 — 每次 ping 后独立计时 */
19368
+ pongTimeoutTimer = null;
19367
19369
  /** 当前重连尝试次数 */
19368
19370
  reconnectAttempts = 0;
19369
19371
  /** 是否处于运行状态 */
@@ -19431,6 +19433,7 @@ var ConnectionManager = class {
19431
19433
  });
19432
19434
  this.client.on("pong", () => {
19433
19435
  this.pongReceived = true;
19436
+ this.clearPongTimeout();
19434
19437
  log13.info("heartbeat: pong received");
19435
19438
  });
19436
19439
  }
@@ -19453,14 +19456,30 @@ var ConnectionManager = class {
19453
19456
  this.pongReceived = false;
19454
19457
  this.client.ping();
19455
19458
  log13.info("heartbeat: ping sent");
19459
+ this.clearPongTimeout();
19460
+ this.pongTimeoutTimer = setTimeout(() => {
19461
+ if (!this.pongReceived && this.running) {
19462
+ log13.warn("heartbeat: pong timeout (independent timer), closing connection");
19463
+ this.client.close(4e3, "pong timeout");
19464
+ this.scheduleReconnect();
19465
+ }
19466
+ }, this.options.heartbeatTimeoutMs);
19456
19467
  }, this.options.heartbeatIntervalMs);
19457
19468
  }
19469
+ /** 清除 pong 超时定时器 */
19470
+ clearPongTimeout() {
19471
+ if (this.pongTimeoutTimer) {
19472
+ clearTimeout(this.pongTimeoutTimer);
19473
+ this.pongTimeoutTimer = null;
19474
+ }
19475
+ }
19458
19476
  /** 停止心跳定时器 */
19459
19477
  stopHeartbeat() {
19460
19478
  if (this.heartbeatTimer) {
19461
19479
  clearInterval(this.heartbeatTimer);
19462
19480
  this.heartbeatTimer = null;
19463
19481
  }
19482
+ this.clearPongTimeout();
19464
19483
  }
19465
19484
  /** 调度重连 (防止并发重连) */
19466
19485
  scheduleReconnect() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liangzimixin",
3
- "version": "0.3.38",
3
+ "version": "0.3.39",
4
4
  "description": "Quantum-encrypted IM channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",