


import { genTestUserSig } from '@/utils/generateTestUserSig';
export default {
    namespaced: true,
    state() {
        return {
            socket: null,
            showdaogou: false,
            sdkAppId: "1400709402",
            userId: '',
            roomId: '',
            role:'',
            secretKey: 'def391b02e6423a6db15eea3d9a0c131f2abac921204246bbe3f36fcea7d111d',
            userSig: 'eJw1jlELgjAURv-LnkPunXNToZceosB6SPsBwVbelrLpFCH675XW43c*Dpwnq4oyMpOjzrBcgkgBVjMbTcdyxiNgy*61vThHmuUoABRkAvjykDZtoCvNAsbAUaWA8u-R7YttFno-JNPou7LBuH0MQR6t2tp6cz-5sy75zrXV3heH9U8M1HySUCapirnC7PUGl3Ix6g__',
            audioDeviceId: '',
            videoDeviceId: '',
            cameraList: [],
            microphoneList: [],
            logs: [],
            isJoined: false,
            isPublished: false,
            isShared: false,
            remoteStreams: [],
            invitedRemoteStreams: [],
        }
    },
    getters: {
        socket: state => {
            return state.socket
        },
        showdaogou: state => {
            return state.showdaogou
        },
        userSig: state => {
            const { userSig } = genTestUserSig({
                sdkAppId: parseInt(state.sdkAppId, 10),
                userId:state.userId,
                secretKey: state.secretKey,
            });
            return userSig
        },
        sdkAppId: state => state.sdkAppId,
        role: state => state.role,
        userId: state => state.userId,
        roomId: state => state.roomId,
        secretKey: state => state.secretKey,
        audioDeviceId: state => state.audioDeviceId,
        videoDeviceId: state => state.videoDeviceId,
        cameraList: state => state.cameraList,
        microphoneList: state => state.microphoneList,
        logs: state => state.logs,
        isJoined: state => state.isJoined,
        isPublished: state => state.isPublished,
        isShared: state => state.isShared,
        remoteStreams: state => state.remoteStreams,
        invitedRemoteStreams: state => state.invitedRemoteStreams
    },
    mutations: {
        setSocket(state, payload) {
            state.socket = payload
        },
        setShowdaogou(state, payload) {
            state.showdaogou = payload
        },

        setUserId(state, payload) {
            state.userId=payload
        },

        setRoomId(state, payload) {
            state.roomId=payload
        },
        setRole(state, payload) {
            state.role=payload
        },

        setDeviceList(state, payload) {
            state.cameraList=payload.cameraItems
            state.microphoneList=payload.microphoneItems
        },

        setVideoDeviceId(state, payload) {
            state.videoDeviceId=payload
        },

        setAudioDeviceId(state, payload) {
            state.audioDeviceId=payload
        },

        setIsJoined(state, payload){
            state.isJoined = payload
        },
        setIsPublished(state, payload){
            state.isPublished = payload
        },
       
    
        // createShareLink(state, payload) {
        //     const userId = `Guest_${Math.floor(Math.random() * 1000000)}`;
        //     const { userSig } = genTestUserSig({
        //         sdkAppId: parseInt(state.sdkAppId, 10),
        //         userId,
        //         secretKey: state.secretKey,
        //     });
        //     const { origin } = window.location;
        //     const { pathname } = window.location;
        //     return `${origin}${pathname}#/invite?userSig=${userSig}&&SDKAppId=${state.sdkAppId}&&userId=${userId}&&roomId=${state.roomId}`;
        // },
        
    },
    actions: {
      
    },
}
