collabdocchat 2.0.1 → 2.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -18,6 +18,10 @@ export const setupWebSocket = (wss) => {
18
18
  case 'auth':
19
19
  handleAuth(ws, data);
20
20
  break;
21
+ case 'ping':
22
+ // 响应心跳
23
+ ws.send(JSON.stringify({ type: 'pong', timestamp: Date.now() }));
24
+ break;
21
25
  case 'join_group':
22
26
  await handleJoinGroup(ws, data);
23
27
  break;
@@ -60,7 +60,11 @@ export class WebSocketService {
60
60
  this.isConnecting = false;
61
61
  this.isAuthenticated = false;
62
62
  this.stopHeartbeat();
63
- this.handleReconnect();
63
+
64
+ // 只有在非正常关闭时才重连
65
+ if (event.code !== 1000 && this.reconnectAttempts < this.maxReconnectAttempts) {
66
+ this.handleReconnect();
67
+ }
64
68
  };
65
69
  } catch (error) {
66
70
  console.error('❌ WebSocket 连接失败:', error);