|
@@ -380,10 +380,14 @@ export const handleMessageHook = async (payload, wsStore) => {
|
|
|
wsStore.toUserAudioInfo = {
|
|
|
uuid: message.from,
|
|
|
type: "user",
|
|
|
- // 接收到来自谁的拨号请求
|
|
|
- fromUuid: message.from,
|
|
|
- fromAvatar: message.avatar,
|
|
|
- fromUsername: message.fromUsername,
|
|
|
+ // 接收到来自谁的拨号请求信息
|
|
|
+ toUuid: message.from,
|
|
|
+ toAvatar: message.avatar,
|
|
|
+ toUsername: message.fromUsername,
|
|
|
+ // 自己的信息
|
|
|
+ fromUuid: message.to,
|
|
|
+ fromAvatar: walletStore.avatar,
|
|
|
+ fromUsername: wsStore.toUserInfo.nickname,
|
|
|
// 发送者信息
|
|
|
sender: {
|
|
|
uuid: message.from,
|
|
@@ -391,17 +395,17 @@ export const handleMessageHook = async (payload, wsStore) => {
|
|
|
nickname: message.fromUsername,
|
|
|
},
|
|
|
};
|
|
|
- wsStore.toUserInfo = {
|
|
|
- ...wsStore.toUserInfo,
|
|
|
- uuid: message.from,
|
|
|
- type: "user",
|
|
|
- unReadNum: 1,
|
|
|
- sender: {
|
|
|
- uuid: message.from,
|
|
|
- avatar: message.avatar,
|
|
|
- nickname: message.fromUsername,
|
|
|
- },
|
|
|
- };
|
|
|
+ // wsStore.toUserInfo = {
|
|
|
+ // ...wsStore.toUserInfo,
|
|
|
+ // uuid: message.from,
|
|
|
+ // type: "user",
|
|
|
+ // unReadNum: 1,
|
|
|
+ // sender: {
|
|
|
+ // uuid: message.from,
|
|
|
+ // avatar: message.avatar,
|
|
|
+ // nickname: message.fromUsername,
|
|
|
+ // },
|
|
|
+ // };
|
|
|
// 调起通话界面
|
|
|
const rtcStore = useWebRTCStore();
|
|
|
rtcStore.streamType = message.contentType == Constant.DIAL_AUDIO_ONLINE ? 'audio' :'video'
|
|
@@ -537,11 +541,15 @@ export const handleMessageHook = async (payload, wsStore) => {
|
|
|
.then(() => rtcStore.createAnswer())
|
|
|
.then((answer) => {
|
|
|
console.log('发送answer给呼叫者', answer)
|
|
|
- // 发送给呼叫者
|
|
|
+ // 发送给被呼叫者(拨打者)
|
|
|
wsStore.sendMessage({
|
|
|
content: JSON.stringify(answer),
|
|
|
type: Constant.MESSAGE_TRANS_TYPE,
|
|
|
messageType: message.contentType,
|
|
|
+ fromUsername: wsStore.toUserAudioInfo.fromUsername,
|
|
|
+ avatar: wsStore.toUserAudioInfo.fromAvatar,
|
|
|
+ to: wsStore.toUserAudioInfo.toUuid,
|
|
|
+ from: wsStore.toUserAudioInfo.fromUuid,
|
|
|
});
|
|
|
})
|
|
|
.catch((error) => {
|
|
@@ -564,6 +572,7 @@ const messageCallback = (contentType, state)=>{
|
|
|
// 创建呼叫:开启语音电话
|
|
|
const startAudioOnline = (video, state) => {
|
|
|
const rtcStore = useWebRTCStore();
|
|
|
+ const wsStore = useWebSocketStore();
|
|
|
// 初始化webrtc连接
|
|
|
rtcStore.initConnection(true, video);
|
|
|
// 获取音视频数据流
|
|
@@ -579,11 +588,15 @@ const startAudioOnline = (video, state) => {
|
|
|
})
|
|
|
.then((offer) => {
|
|
|
console.log('caller', offer)
|
|
|
- // 发送offer给被呼叫者
|
|
|
+ // 发送offer给被呼叫者(接听者)
|
|
|
state.sendMessage({
|
|
|
contentType: video? Constant.VIDEO_ONLINE: Constant.AUDIO_ONLINE, // 消息内容类型
|
|
|
content: JSON.stringify(offer),
|
|
|
type: Constant.MESSAGE_TRANS_TYPE,
|
|
|
+ fromUsername: wsStore.toUserAudioInfo.fromUsername,
|
|
|
+ avatar: wsStore.toUserAudioInfo.fromAvatar,
|
|
|
+ to: wsStore.toUserAudioInfo.toUuid,
|
|
|
+ from: wsStore.toUserAudioInfo.fromUuid,
|
|
|
});
|
|
|
})
|
|
|
.catch((error) => {
|