import Agora, {
    AgoraEvent,
    AgoraStatus
} from "$utils/agora/agora";

import AgoraRTMIM from '$utils/socket/agoraRTM/agoraRTMIM';

import user from '$config/user';

export default <LibMixins>{

    data(){
      return {
          agoraStatus: AgoraStatus.none
      }
    },

    created(){

        this.useAgora = new Agora(this.$params.rid.toString(),user.uid() || null);

        this.agoraRTMIM = new AgoraRTMIM();

        // 监听设置状态
        this.useAgora.on(AgoraEvent.status,(item)=>{
            this.agoraStatus = item;
        });

    },

    beforeUnmount(){
        // 释放
        this.useAgora && this.useAgora.destroy();
        // 释放聊天
        this.agoraRTMIM && this.agoraRTMIM.destroy();
    }

}
