feat: 消息与socket的优化调整
This commit is contained in:
@@ -28,10 +28,11 @@ export class WebSocketManager {
|
||||
|
||||
// 回调函数
|
||||
this.callbacks = {
|
||||
onConnect: options.onConnect || (() => {}),
|
||||
onDisconnect: options.onDisconnect || (() => {}),
|
||||
onError: options.onError || (() => {}),
|
||||
onMessage: options.onMessage || (() => {}),
|
||||
// 支持两套回调命名:onConnect/onDisconnect 与 onOpen/onClose(兼容调用方)
|
||||
onConnect: options.onConnect || options.onOpen || (() => { }),
|
||||
onDisconnect: options.onDisconnect || options.onClose || (() => { }),
|
||||
onError: options.onError || (() => { }),
|
||||
onMessage: options.onMessage || (() => { }),
|
||||
getConversationId: options.getConversationId || (() => ""),
|
||||
getAgentId: options.getAgentId || (() => ""),
|
||||
};
|
||||
@@ -327,7 +328,7 @@ export class WebSocketManager {
|
||||
const messageData = {
|
||||
...message,
|
||||
timestamp: Date.now(),
|
||||
retryCount: 0,
|
||||
retryCount: typeof message.retryCount === 'number' ? message.retryCount : 0,
|
||||
};
|
||||
|
||||
if (this.connectionState) {
|
||||
@@ -392,7 +393,7 @@ export class WebSocketManager {
|
||||
agentId: this.callbacks.getAgentId
|
||||
? this.callbacks.getAgentId()
|
||||
: "",
|
||||
messageType: 3, // 心跳检测
|
||||
messageType: '3', // 心跳检测
|
||||
messageContent: "heartbeat",
|
||||
messageId: IdUtils.generateMessageId(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user