【m】聊天消息接入
This commit is contained in:
@@ -366,7 +366,7 @@ function onCandidate(ws: WebSocket, message: any): void {
|
||||
* @param ws WebSocket连接实例
|
||||
* @param message 消息数据
|
||||
*/
|
||||
function onChatMessage(ws: WebSocket, message: any): void {
|
||||
function onMessage(ws: WebSocket, message: any): void {
|
||||
// 获取连接ID
|
||||
const connectionId = message.connectionId;
|
||||
const chatMessage = message.message;
|
||||
@@ -376,11 +376,11 @@ function onCandidate(ws: WebSocket, message: any): void {
|
||||
const otherSessionWs = pair[0] == ws ? pair[1] : pair[0];
|
||||
if (otherSessionWs) {
|
||||
// 发送chat-message消息
|
||||
otherSessionWs.send(JSON.stringify({ from: connectionId, to: "", type: "chat-message", data: chatMessage }));
|
||||
otherSessionWs.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: chatMessage }));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 导出WebSocket处理器函数
|
||||
*/
|
||||
export { reset, add, remove, onConnect, onDisconnect, onOffer, onAnswer, onCandidate, onCallConnectionId, onBroadcast, onGetAllConnectionIds, AddHeartbeat, RemoveHeartbeat ,onChatMessage};
|
||||
export { reset, add, remove, onConnect, onDisconnect, onOffer, onAnswer, onCandidate, onCallConnectionId, onBroadcast, onGetAllConnectionIds, AddHeartbeat, RemoveHeartbeat ,onMessage};
|
||||
|
||||
@@ -108,9 +108,9 @@ export default class WSSignaling {
|
||||
// 处理callConnectionId信令
|
||||
handler.onCallConnectionId(ws, msg.data);
|
||||
break;
|
||||
case 'chat-message'://接受连接ConnectionId
|
||||
case 'on-message'://接受连接ConnectionId
|
||||
// 处理chat-message信令
|
||||
handler.onChatMessage(ws, msg.data);
|
||||
handler.onMessage(ws, msg.data);
|
||||
break;
|
||||
default:
|
||||
// 忽略未知消息类型
|
||||
|
||||
Reference in New Issue
Block a user