message修改为data
This commit is contained in:
@@ -62,7 +62,7 @@ function sendChatMessage(message) {
|
||||
if (store.getRenderStreaming()) {
|
||||
store.getRenderStreaming().sendMessage({
|
||||
type: 'chat-message',
|
||||
message: message,
|
||||
data: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,39 +715,38 @@ class CallStateManager {
|
||||
this.renderstreaming.onMessage = (data) => {
|
||||
console.log('收到消息:', data);
|
||||
if (data.type === 'chat-message') {
|
||||
// 处理聊天
|
||||
// 添加到列表并更新UI
|
||||
chatMessage.handleChatMessage(data.message);
|
||||
// Host端:按participantId更新对应用户信息
|
||||
const chatPayload = data.data || data.message;
|
||||
if (!chatPayload) {
|
||||
return;
|
||||
}
|
||||
|
||||
chatMessage.handleChatMessage(chatPayload);
|
||||
if (data.participantId && this.role === 'host' && this.state.participants[data.participantId]) {
|
||||
this.state.participants[data.participantId].id = data.message.senderId;
|
||||
if (data.message.senderName) {
|
||||
this.state.participants[data.participantId].name = data.message.senderName;
|
||||
this.state.participants[data.participantId].id = chatPayload.senderId;
|
||||
if (chatPayload.senderName) {
|
||||
this.state.participants[data.participantId].name = chatPayload.senderName;
|
||||
}
|
||||
if (data.message.senderAvatar) {
|
||||
this.state.participants[data.participantId].avatar = data.message.senderAvatar;
|
||||
if (chatPayload.senderAvatar) {
|
||||
this.state.participants[data.participantId].avatar = chatPayload.senderAvatar;
|
||||
}
|
||||
this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants });
|
||||
this.broadcastParticipantsList();
|
||||
}
|
||||
// Participant端:根据消息来源更新对应用户信息
|
||||
if (!this.role || this.role !== 'host') {
|
||||
if (data.participantId && this.state.participants[data.participantId]) {
|
||||
// 来自其他Participant的消息:更新participants中对应条目
|
||||
if (data.message.senderName) {
|
||||
this.state.participants[data.participantId].name = data.message.senderName;
|
||||
if (chatPayload.senderName) {
|
||||
this.state.participants[data.participantId].name = chatPayload.senderName;
|
||||
}
|
||||
if (data.message.senderAvatar) {
|
||||
this.state.participants[data.participantId].avatar = data.message.senderAvatar;
|
||||
if (chatPayload.senderAvatar) {
|
||||
this.state.participants[data.participantId].avatar = chatPayload.senderAvatar;
|
||||
}
|
||||
this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants });
|
||||
} else if (data.message && data.message.senderId !== this.state.session.localUser.id) {
|
||||
// 来自Host的消息:更新remoteUser
|
||||
} else if (chatPayload.senderId !== this.state.session.localUser.id) {
|
||||
this.state.session.remoteUser = {
|
||||
...this.state.session.remoteUser,
|
||||
id: data.message.senderId,
|
||||
name: data.message.senderName,
|
||||
avatar: data.message.senderAvatar
|
||||
id: chatPayload.senderId,
|
||||
name: chatPayload.senderName,
|
||||
avatar: chatPayload.senderAvatar
|
||||
};
|
||||
this.notify({ type: 'REMOTE_MEDIA_CHANGE', mediaState: this.state.session.remoteUser.mediaState });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user