|
@@ -37,6 +37,7 @@ import {
|
|
|
WsOtherJoinType,
|
|
WsOtherJoinType,
|
|
|
WsRoomLivingType,
|
|
WsRoomLivingType,
|
|
|
WsStartLiveType,
|
|
WsStartLiveType,
|
|
|
|
|
+ WsUpdateJoinInfoType,
|
|
|
} from '@/types/websocket';
|
|
} from '@/types/websocket';
|
|
|
import { createVideo } from '@/utils';
|
|
import { createVideo } from '@/utils';
|
|
|
|
|
|
|
@@ -52,6 +53,7 @@ export const useWebsocket = () => {
|
|
|
|
|
|
|
|
const { maxBitrate, maxFramerate, resolutionRatio } = useRTCParams();
|
|
const { maxBitrate, maxFramerate, resolutionRatio } = useRTCParams();
|
|
|
|
|
|
|
|
|
|
+ const connectStatus = ref();
|
|
|
const loopHeartbeatTimer = ref();
|
|
const loopHeartbeatTimer = ref();
|
|
|
const loopGetLiveUserTimer = ref();
|
|
const loopGetLiveUserTimer = ref();
|
|
|
const liveUserList = ref<ILiveUser[]>([]);
|
|
const liveUserList = ref<ILiveUser[]>([]);
|
|
@@ -88,6 +90,24 @@ export const useWebsocket = () => {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ watch(
|
|
|
|
|
+ [() => userStore.userInfo?.id, () => connectStatus.value],
|
|
|
|
|
+ ([userInfo, status]) => {
|
|
|
|
|
+ if (userInfo && status === WsConnectStatusEnum.connect) {
|
|
|
|
|
+ const ws = networkStore.wsMap.get(roomId.value);
|
|
|
|
|
+ if (!ws) return;
|
|
|
|
|
+ ws.send<WsUpdateJoinInfoType['data']>({
|
|
|
|
|
+ requestId: getRandomString(8),
|
|
|
|
|
+ msgType: WsMsgTypeEnum.updateJoinInfo,
|
|
|
|
|
+ data: {
|
|
|
|
|
+ live_room_id: Number(roomId.value),
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ { immediate: true }
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
const mySocketId = computed(() => {
|
|
const mySocketId = computed(() => {
|
|
|
return networkStore.wsMap.get(roomId.value)?.socketIo?.id || '-1';
|
|
return networkStore.wsMap.get(roomId.value)?.socketIo?.id || '-1';
|
|
|
});
|
|
});
|
|
@@ -418,6 +438,7 @@ export const useWebsocket = () => {
|
|
|
prettierReceiveWsMsg(WsConnectStatusEnum.connect, ws.socketIo);
|
|
prettierReceiveWsMsg(WsConnectStatusEnum.connect, ws.socketIo);
|
|
|
handleHeartbeat(ws.socketIo!.id);
|
|
handleHeartbeat(ws.socketIo!.id);
|
|
|
if (!ws) return;
|
|
if (!ws) return;
|
|
|
|
|
+ connectStatus.value = WsConnectStatusEnum.connect;
|
|
|
ws.status = WsConnectStatusEnum.connect;
|
|
ws.status = WsConnectStatusEnum.connect;
|
|
|
ws.update();
|
|
ws.update();
|
|
|
sendJoin();
|
|
sendJoin();
|
|
@@ -671,7 +692,6 @@ export const useWebsocket = () => {
|
|
|
ws.socketIo.on(
|
|
ws.socketIo.on(
|
|
|
WsMsgTypeEnum.liveUser,
|
|
WsMsgTypeEnum.liveUser,
|
|
|
(data: WSGetRoomAllUserType['data']) => {
|
|
(data: WSGetRoomAllUserType['data']) => {
|
|
|
- console.log('当前所有在线用户', data.liveUser);
|
|
|
|
|
prettierReceiveWsMsg(WsMsgTypeEnum.liveUser, data);
|
|
prettierReceiveWsMsg(WsMsgTypeEnum.liveUser, data);
|
|
|
liveUserList.value = data.liveUser;
|
|
liveUserList.value = data.liveUser;
|
|
|
}
|
|
}
|