@eyeclaw/eyeclaw 2.3.3 → 2.3.4
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 +1 -1
- package/src/websocket-client.ts +20 -2
package/package.json
CHANGED
package/src/websocket-client.ts
CHANGED
|
@@ -103,11 +103,17 @@ export class EyeClawWebSocketClient {
|
|
|
103
103
|
return
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
// Ping/pong
|
|
106
|
+
// Ping/pong (协议级别的 ping,直接响应 pong)
|
|
107
107
|
if (message.type === 'ping') {
|
|
108
108
|
this.send({ type: 'pong' })
|
|
109
109
|
return
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
// 处理 Rails BotChannel 的 pong 响应
|
|
113
|
+
if (message.type === 'pong') {
|
|
114
|
+
this.api.logger.debug('[EyeClaw] Received pong from server')
|
|
115
|
+
return
|
|
116
|
+
}
|
|
111
117
|
|
|
112
118
|
// Subscription confirmation
|
|
113
119
|
if (message.type === 'confirm_subscription') {
|
|
@@ -320,7 +326,19 @@ export class EyeClawWebSocketClient {
|
|
|
320
326
|
*/
|
|
321
327
|
private startPing() {
|
|
322
328
|
this.pingInterval = setInterval(() => {
|
|
323
|
-
|
|
329
|
+
// 调用 Rails BotChannel 的 ping action
|
|
330
|
+
const channelIdentifier = JSON.stringify({
|
|
331
|
+
channel: 'BotChannel',
|
|
332
|
+
bot_id: this.config.botId,
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
this.send({
|
|
336
|
+
command: 'message',
|
|
337
|
+
identifier: channelIdentifier,
|
|
338
|
+
data: JSON.stringify({
|
|
339
|
+
action: 'ping',
|
|
340
|
+
}),
|
|
341
|
+
})
|
|
324
342
|
}, 60000) // 60秒心跳一次
|
|
325
343
|
}
|
|
326
344
|
|