import type IMessageEventPlugin from '../../IMessageEventPlugin'
import type VideoCall from '../mode/VideoCall'
import type VideoSendInfo from '../mode/VideoSendInfo'
import { usePeerStore } from '@/store/peerStore'
import SendVideoCode from "@/plugins/video/SendVideoCode";

class IMessageEventCall implements IMessageEventPlugin<VideoCall> {
  //代码类型
  code = SendVideoCode.CALL

  //监听消息
  listener(videoSendInfo: VideoSendInfo<VideoCall>) {
    const { message } = videoSendInfo
    //如果已经在通话中，就不再接受新的通话
    if (usePeerStore().isBusy) {
      return
    }
    uni.navigateTo({
      url: `/plugins/video/VideoCalling?friendId=${message.fromId}&peerId=${message.peerId}&showVideo=${message.showVideo}`
    })
  }
}
export default IMessageEventCall
