消息模块开发完成

This commit is contained in:
2026-05-18 23:03:28 +08:00
parent 2c6a7af31b
commit 85c0b0226d
6 changed files with 202 additions and 5 deletions

View File

@@ -378,7 +378,15 @@ function onCallConnectionId(ws: WebSocket, message: any): void {
});
}
}
function onHostUserInfo(ws: WebSocket, message: any): void {
(ws as any).userInfo = {
id: message.id || '',
name: message.name || '匿名用户',
avatar: message.avatar || ''
};
log(LogLevel.log, 'Updated current ws userInfo:', (ws as any).userInfo);
}
/**
* 处理广播消息请求1对多模式
@@ -555,4 +563,4 @@ function onMessage(ws: WebSocket, message: any): void {
/**
* 导出WebSocket处理器函数
*/
export { reset, add, remove, onConnect, onDisconnect, onOffer, onAnswer, onCandidate, onCallConnectionId, onBroadcast, onGetAllConnectionIds, onGetOnlineUsers, AddHeartbeat, RemoveHeartbeat, onMessage, isHost, broadcastToGroup, connectionGroup };
export { reset, add, remove, onConnect, onDisconnect, onOffer, onAnswer, onCandidate, onCallConnectionId, onBroadcast, onGetAllConnectionIds, onGetOnlineUsers, AddHeartbeat, RemoveHeartbeat, onMessage, isHost, broadcastToGroup, connectionGroup, onHostUserInfo };

View File

@@ -105,6 +105,18 @@ export default class WSSignaling {
case 'call-request':
handler.onCallConnectionId(ws, msg.data);
break;
case 'host-userInfo':
handler.onHostUserInfo(ws, msg.data);
break;
// case 'invite-call':
// handler.onInviteCall(ws, msg.data);
// break;
// case 'invite-accepted':
// handler.onInviteAccepted(ws, msg.data);
// break;
// case 'invite-rejected':
// handler.onInviteRejected(ws, msg.data);
// break;
case 'on-message':
if (msg.from) msg.data.connectionId = msg.from;
handler.onMessage(ws, msg.data);