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