123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class PeerView : BaseView
- {
- public Text tName;
- public RawImage mViewTexture;
- public Button mainBtn;
- public GameObject user;
- //public GameObject add;
- public SysEnterManager sysEenter;
- public CustomPeer cPeer;
- //public Button addBtn;
- private InviteUserConfig inviteUserConfig;
- private float alltime = 30f;
- private bool istime = false;
- public Texture texture;
- public GameObject ChooseKuang;
- private void ShowChooseKuang(string id)
- {
- if (id == cPeer.peerId)
- {
- ChooseKuang.SetActive(true);
- if (ShowUserMsg.Instance)
- {
- ShowUserMsg.Instance.Init(this.cPeer);
- }
- }
- else
- {
- ChooseKuang.SetActive(false);
- }
- }
- private void Update()
- {
- if (istime)
- {
- alltime -= Time.deltaTime;
- if (alltime <= 0)
- {
- istime = false;
- alltime = 30f;
- if (this.inviteUserConfig != null)
- {
- //if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList.Contains(this.inviteUserConfig))
- //{
- // PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, this.inviteUserConfig.NickName + "无应答");
- // InviteDlg.Instance.InvitingUnionIdList.Remove(this.inviteUserConfig);
- // RoomOtherUser.Instance.UpdateList();
- //}
- }
- }
- }
- else
- {
- alltime = 30f;
- }
- }
- public override void Init(int i, BaseConfig c, int vi)
- {
- base.Init(i, c, vi);
- mainBtn.onClick.RemoveAllListeners();
- mainBtn.onClick.AddListener(setBigView);
- if (c is PeerConfig)
- {
- if (this.inviteUserConfig != null)
- {
- this.inviteUserConfig = null;
- }
- user.SetActive(true);
- //add.SetActive(false);
- sysEenter.gameObject.SetActive(true);
- cPeer = (c as PeerConfig).peer;
- sysEenter.cPeer = cPeer;
- tName.text = cPeer.name;
-
- if (!cPeer.isSn)
- {
- if (!string.IsNullOrEmpty(cPeer.avater))
- {
- NetWorkHeaders.Instance.getNetTexture(cPeer.avater, null, (Texture tex) => {
- mViewTexture.texture = tex;
- });
- }
- else
- {
- if (UserInfo.defaulttextIcon != null)
- {
- mViewTexture.texture = UserInfo.defaulttextIcon;
- }
- }
- }
- else
- {
- NetWorkHeaders.GetUserAvater((aData) =>
- {
- for (int j = 0; j < aData["data"]["sn"].Count; j++)
- {
- NetWorkHeaders.Instance.getNetTexture(aData["data"]["sn"][j].ToString(), null, (Texture tex) => {
- mViewTexture.texture = tex;
- });
- }
- });
- }
- cPeer.onChangeInfo -= OnChangeInfo;
- cPeer.onChangeInfo += OnChangeInfo;
- cPeer.onChangeTexture -= onChangeTexture;
- cPeer.onChangeTexture += onChangeTexture;
- cPeer.onChangeName -= onChangeName;
- cPeer.onChangeName += onChangeName;
- RoomOtherUser.ShowAction -= ShowChooseKuang;
- RoomOtherUser.ShowAction += ShowChooseKuang;
- if (RoomMainForms.userId == RoomMainForms.NOUSER)
- {
- RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId);
- }
- alltime = 30f;
- istime = false;
- }
- else if (c is InviteUserConfig)
- {
- if (cPeer != null)
- {
- cPeer = null;
- }
- this.inviteUserConfig = c as InviteUserConfig;
- user.SetActive(true);
- //add.SetActive(false);
- tName.text = "等待进入...";
- sysEenter.gameObject.SetActive(false);
- if (this.inviteUserConfig != null && !string.IsNullOrEmpty(inviteUserConfig.Avatar))
- {
- NetWorkHeaders.Instance.getNetTexture(inviteUserConfig.Avatar, null, (Texture tex) => {
- mViewTexture.texture = tex;
- });
- }
- else
- {
- if (UserInfo.defaulttextIcon != null)
- {
- mViewTexture.texture = UserInfo.defaulttextIcon;
- }
- }
- alltime = 30f;
- istime = true;
- }
- //else
- //{
- // user.SetActive(false);
- // add.SetActive(true);
- // alltime = 30f;
- // istime = false;
- //}
- AgoraVideoAudioManager.Instance.listCustomPeer.Add(cPeer);
- }
- void onChangeTexture()
- {
- if (RoomMainForms.userId == cPeer.peerId)
- {
- RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId);
- }
- }
- void onChangeName(string cName)
- {
- tName.text = cName;
- }
- public void setBigView()
- {
- if (cPeer == null)
- {
- return;
- }
- RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId);
- RoomMainForms.Instance.ClickOnCloseCoordinate();
- //RoomOtherUser.ShowAction?.Invoke(cPeer.peerId);
- // AgoraVideoAudioManager.Instance.AddListShowView(cPeer.peerId, RoomMainForms.Instance.bigView);
- }
- private void ClickAdd()
- {
- //if (ShowRoom.Instance)
- //{
- // ShowRoom.Instance.window[4].SetActive(true);
- // if (InviteDlg.Instance)
- // {
- // InviteDlg.Instance.ShowHistory();
- // }
- //}
- }
- private void OnChangeInfo(string type, string id)
- {
- if (type == "video")
- {
- if (cPeer.isVideo)
- {
- if (cPeer.isCloseVideo)
- {
- RemoteRtc.Instance.closeRev(cPeer.cIdV);
- }
- }
- if (RoomMainForms.userId == cPeer.peerId)
- {
- Debug.Log("开启大视频");
- RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId);
- }
- }
- else
- {
- if (cPeer.isAudio)
- {
- if (cPeer.isCloseAudio)
- {
- RemoteRtc.Instance.closeRev(cPeer.cIdA);
- }
- }
- }
- }
- public void OpenVideo()
- {
- if (cPeer != null && cPeer.isVideo && cPeer.cIdV != "" && cPeer.isCloseVideo)
- {
- RemoteRtc.Instance.startRev(cPeer.cIdV);
- //cPeer.isCloseVideo = false;
- }
- cPeer.isCloseVideo = false;
- AgoraVideoAudioManager.Instance.MuteRemoteVideoStream(cPeer.peerId, false);
- }
- public void CloseVideo()
- {
- if (cPeer != null && cPeer.isVideo && cPeer.cIdV != "" && !cPeer.isCloseVideo)
- {
- RemoteRtc.Instance.closeRev(cPeer.cIdV);
- // cPeer.isCloseVideo = true;
- }
-
- cPeer.isCloseVideo = true;
- AgoraVideoAudioManager.Instance.MuteRemoteVideoStream(cPeer.peerId, true);
- }
- public void openMic()
- {
- if (cPeer != null && cPeer.isAudio && cPeer.cIdA != "" && cPeer.isCloseAudio)
- {
- RemoteRtc.Instance.startRev(cPeer.cIdA);
- cPeer.isCloseAudio = false;
- }
- AgoraVideoAudioManager.Instance.MuteRemoteAudioStream(cPeer.peerId, false);
- cPeer.isCloseAudio = false;
- }
- public void closeMic()
- {
- if (cPeer != null && cPeer.isAudio && cPeer.cIdA != "" && !cPeer.isCloseAudio)
- {
- RemoteRtc.Instance.closeRev(cPeer.cIdA);
- cPeer.isCloseAudio = true;
- }
- AgoraVideoAudioManager.Instance.MuteRemoteAudioStream(cPeer.peerId, true);
- cPeer.isCloseAudio = true;
- }
- public void ChangeVideo( bool isVideo)
- {
- cPeer.isVideo = isVideo;
- }
- public void ChangeAudio(bool isAudio)
- {
- cPeer.isAudio = isAudio;
- }
- }
|