完成
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Script
|
||||
private Text _confirmBtnTimeText;
|
||||
private Button _confirmButton;
|
||||
private bool _isCountingDown;
|
||||
private MeetingContacts _meetingContacts;
|
||||
private MeetingContactsController _meetingContactsController;
|
||||
private Transform _messageText;
|
||||
private Transform _nameText;
|
||||
private MainPanel.UsersItem _usersItem;
|
||||
@@ -33,10 +33,10 @@ namespace Script
|
||||
return MainArchitecture.Interface;
|
||||
}
|
||||
|
||||
public void SetData(MainPanel.UsersItem item, MeetingContacts meetingContactsController)
|
||||
public void SetData(MainPanel.UsersItem item, MeetingContactsController meetingContactsControllerController)
|
||||
{
|
||||
_usersItem = item;
|
||||
_meetingContacts = meetingContactsController;
|
||||
_meetingContactsController = meetingContactsControllerController;
|
||||
|
||||
_background = transform.Find("headBackground/image").GetComponent<Image>();
|
||||
_backgroundName = transform.Find("headBackground/Name").GetComponent<Text>();
|
||||
@@ -120,9 +120,9 @@ namespace Script
|
||||
Debug.Log($"点击了联系人: {_usersItem.name}");
|
||||
// 这里可以添加点击联系人后的逻辑,比如打开聊天窗口
|
||||
// 或者发送邀请请求等
|
||||
_meetingContacts.ClickContactEntry(_background.GetComponent<Image>().sprite,
|
||||
_meetingContactsController.ClickContactEntry(_background.GetComponent<Image>().sprite,
|
||||
_backgroundName.GetComponent<Text>().text, _usersItem);
|
||||
_meetingContacts.CurrentEntry = this;
|
||||
_meetingContactsController.CurrentEntry = this;
|
||||
}
|
||||
|
||||
public void StartCountdown()
|
||||
|
||||
@@ -28,17 +28,17 @@ namespace Script
|
||||
/// <summary>
|
||||
/// 会议联系人类和面板
|
||||
/// </summary>
|
||||
private MeetingContacts _meetingContacts;
|
||||
private MeetingContactsController _meetingContactsController;
|
||||
|
||||
/// <summary>
|
||||
/// 会议参与者列表和面板
|
||||
/// </summary>
|
||||
private MeetingInfoList _meetingInfoList;
|
||||
private MeetingInfoListController _meetingInfoListController;
|
||||
|
||||
/// <summary>
|
||||
/// 会议聊天面板
|
||||
/// </summary>
|
||||
private MeetingChat _meetingChat;
|
||||
private MeetingChatController _meetingChatController;
|
||||
|
||||
/// <summary>
|
||||
/// 房间人数
|
||||
@@ -80,18 +80,18 @@ namespace Script
|
||||
_contactsTog = panelGo.transform.Find("Tabs/Contacts").GetComponent<Toggle>();
|
||||
_meetingOrganizersTog = panelGo.transform.Find("Tabs/MeetingOrganizers").GetComponent<Toggle>();
|
||||
|
||||
_meetingContacts = new MeetingContacts();
|
||||
_meetingContacts.Initialize(panelGo.transform.Find("MeetingContacts").gameObject);
|
||||
_meetingInfoList = new MeetingInfoList();
|
||||
_meetingInfoList.Initialize(panelGo.transform.Find("MeetingInfoList").gameObject, this);
|
||||
_meetingChat = new MeetingChat();
|
||||
_meetingChat.Initialize(panelGo.transform.Find("MeetingChat").gameObject, this);
|
||||
_meetingContactsController = new MeetingContactsController();
|
||||
_meetingContactsController.Initialize(panelGo.transform.Find("MeetingContacts").gameObject);
|
||||
_meetingInfoListController = new MeetingInfoListController();
|
||||
_meetingInfoListController.Initialize(panelGo.transform.Find("MeetingInfoList").gameObject, this);
|
||||
_meetingChatController = new MeetingChatController();
|
||||
_meetingChatController.Initialize(panelGo.transform.Find("MeetingChat").gameObject, this);
|
||||
}
|
||||
|
||||
public override void OnEnter(Action complete = null)
|
||||
{
|
||||
base.OnEnter(complete);
|
||||
_meetingInfoList.OnEnter();
|
||||
_meetingInfoListController.OnEnter();
|
||||
_titleText.text = this.GetSystem<IGlobalConfigSystem>().GetConnectionName();
|
||||
this.GetSystem<IGlobalConfigSystem>().StartConnectionTime(_timeText);
|
||||
_idText.text = this.GetSystem<IGlobalConfigSystem>().GetConnectionId();
|
||||
@@ -107,7 +107,7 @@ namespace Script
|
||||
public override void OnExit(float delay = 0)
|
||||
{
|
||||
base.OnExit(delay);
|
||||
_meetingInfoList.OnExit();
|
||||
_meetingInfoListController.OnExit();
|
||||
_arrowLeft.onClick.RemoveListener(OnArrowLeftClick);
|
||||
_chatTog.onValueChanged.RemoveListener(OnChatTog);
|
||||
_contactsTog.onValueChanged.RemoveListener(OnContactsTog);
|
||||
@@ -131,7 +131,7 @@ namespace Script
|
||||
}
|
||||
|
||||
// 更新会议聊天面板人数
|
||||
_meetingChat.OnUserCountChangedEvent?.Invoke(obj.Count);
|
||||
_meetingChatController.OnUserCountChangedEvent?.Invoke(obj.Count);
|
||||
}
|
||||
|
||||
private void OnUsersChangedDisconnected(string obj)
|
||||
@@ -152,26 +152,26 @@ namespace Script
|
||||
}
|
||||
|
||||
_roomPeopleNumText.text = _userMap.Count.ToString();
|
||||
_meetingChat.OnUserCountChangedEvent?.Invoke(_userMap.Count);
|
||||
_meetingChatController.OnUserCountChangedEvent?.Invoke(_userMap.Count);
|
||||
}
|
||||
|
||||
private void OnMeetingOrganizersTog(bool value)
|
||||
{
|
||||
_meetingInfoList.PanelGo.SetActive(value);
|
||||
_meetingInfoListController.PanelGo.SetActive(value);
|
||||
}
|
||||
|
||||
private void OnContactsTog(bool value)
|
||||
{
|
||||
_meetingContacts.PanelGo.SetActive(value);
|
||||
_meetingContactsController.PanelGo.SetActive(value);
|
||||
if (value)
|
||||
_meetingContacts.OnEnter();
|
||||
_meetingContactsController.OnEnter();
|
||||
}
|
||||
|
||||
private void OnChatTog(bool value)
|
||||
{
|
||||
_meetingChat.PanelGo.SetActive(value);
|
||||
_meetingChatController.PanelGo.SetActive(value);
|
||||
if (value)
|
||||
_meetingChat.OnEnter();
|
||||
_meetingChatController.OnEnter();
|
||||
}
|
||||
|
||||
private void OnArrowLeftClick()
|
||||
@@ -181,8 +181,8 @@ namespace Script
|
||||
public override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
_meetingChat.OnDestroy();
|
||||
_meetingContacts.OnDestroy();
|
||||
_meetingChatController.OnDestroy();
|
||||
_meetingContactsController.OnDestroy();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using RenderStreaming;
|
||||
using Script.Util;
|
||||
@@ -10,7 +11,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Script
|
||||
{
|
||||
public class MeetingChat : IController
|
||||
public class MeetingChatController : IController
|
||||
{
|
||||
public GameObject PanelGo;
|
||||
private MainPanel _mainPanel;
|
||||
@@ -62,6 +63,9 @@ namespace Script
|
||||
_objectLeftPool.AllRelease();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送聊天信息
|
||||
/// </summary>
|
||||
private void OnSendButtonClick()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_messageInput.text)) return;
|
||||
@@ -97,6 +101,9 @@ namespace Script
|
||||
SignalingMessageHelper.SendMessage(JsonConvert.SerializeObject(send));
|
||||
_messageInput.text = "";
|
||||
chatData.isSelf = !chatData.isSelf;
|
||||
var utc = DateTimeOffset.Parse(chatData.timestamp, CultureInfo.InvariantCulture);
|
||||
var local = utc.ToLocalTime().ToString("HH:mm");
|
||||
chatData.timestamp = local;
|
||||
_chatDatas.Add(chatData);
|
||||
var entry = _objectRightPool.Get();
|
||||
SetMessageEntry(chatData, entry);
|
||||
@@ -119,7 +126,7 @@ namespace Script
|
||||
var name = entry.transform.Find("name");
|
||||
var message = entry.transform.Find("message");
|
||||
var sprite = entry.transform.Find("sprite");
|
||||
|
||||
var time = entry.transform.Find("message/messagebg/time");
|
||||
if (string.IsNullOrEmpty(data.senderAvatar))
|
||||
{
|
||||
var randomColor = WebRTCUtil.GetRandomColor();
|
||||
@@ -148,6 +155,11 @@ namespace Script
|
||||
new Rect(0, 0, texture.width, texture.height),
|
||||
Vector2.one);
|
||||
}
|
||||
|
||||
var utc = DateTimeOffset.Parse(data.timestamp, CultureInfo.InvariantCulture);
|
||||
var local = utc.ToLocalTime().ToString("HH:mm");
|
||||
data.timestamp = local;
|
||||
time.GetComponent<Text>().text = data.timestamp;
|
||||
}
|
||||
|
||||
private void OnUserCountChanged(int obj)
|
||||
@@ -9,7 +9,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Script
|
||||
{
|
||||
public class MeetingContacts : IController
|
||||
public class MeetingContactsController : IController
|
||||
{
|
||||
/// <summary>
|
||||
/// 联系人列表项字典
|
||||
@@ -1,14 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using RenderStreaming;
|
||||
using Script.Util;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.UIFarme;
|
||||
using Unity.RenderStreaming;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Script
|
||||
{
|
||||
public class MeetingInfoList : IController
|
||||
public class MeetingInfoListController : IController
|
||||
{
|
||||
private MainPanel _mainPanel;
|
||||
public GameObject PanelGo;
|
||||
@@ -29,6 +31,15 @@ namespace Script
|
||||
|
||||
private GameObjectPool _objectPool;
|
||||
|
||||
|
||||
private Toggle _micTog;
|
||||
private Toggle _videoTog;
|
||||
private Toggle _recordTog;
|
||||
private Button _hangUpTog;
|
||||
|
||||
private AudioStreamSender _audioStreamSender;
|
||||
private VideoStreamSender _videoStreamSender;
|
||||
|
||||
public void Initialize(GameObject panelGo, MainPanel mainPanel)
|
||||
{
|
||||
PanelGo = panelGo;
|
||||
@@ -37,18 +48,88 @@ namespace Script
|
||||
_content = panelGo.transform.Find("MeetingGrid/Viewport/Content");
|
||||
_meetingNum = panelGo.transform.Find("MeetingNum/Num").GetComponent<Text>();
|
||||
_objectPool = PanelGo.transform.Find("MeetingGrid/Pool").GetComponent<GameObjectPool>();
|
||||
_micTog = PanelGo.transform.Find("menuBar/mic").GetComponent<Toggle>();
|
||||
_videoTog = PanelGo.transform.Find("menuBar/video").GetComponent<Toggle>();
|
||||
_recordTog = PanelGo.transform.Find("menuBar/record").GetComponent<Toggle>();
|
||||
_hangUpTog = PanelGo.transform.Find("menuBar/hangUp").GetComponent<Button>();
|
||||
_audioStreamSender = GameObject.Find("RenderStreaming").GetComponent<AudioStreamSender>();
|
||||
_videoStreamSender = GameObject.Find("RenderStreaming").GetComponent<VideoStreamSender>();
|
||||
}
|
||||
|
||||
public void OnEnter()
|
||||
{
|
||||
LoadUsers();
|
||||
_micTog.onValueChanged.AddListener(OnMicTogValueChanged);
|
||||
_videoTog.onValueChanged.AddListener(OnVideoTogValueChanged);
|
||||
_recordTog.onValueChanged.AddListener(OnRecordTogValueChanged);
|
||||
_hangUpTog.onClick.AddListener(OnHangUpTogValueChanged);
|
||||
|
||||
GameObject.FindObjectOfType<MessageChannel>().OnMediaStateChangeReceived += OnMediaStateChangeReceived;
|
||||
GameObject.FindObjectOfType<MessageChannel>().OnUserInfoMessageReceived += OnUserInfoMessageReceived;
|
||||
GameObject.FindObjectOfType<HostConnection>().OnParticipantDisconnected += OnParticipantDisconnected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
private void OnMicTogValueChanged(bool value)
|
||||
{
|
||||
var message = new
|
||||
{
|
||||
type = "on-message",
|
||||
data = new
|
||||
{
|
||||
connectionId = this.GetSystem<IGlobalConfigSystem>().GetConnectionId(),
|
||||
message = new
|
||||
{
|
||||
type = "media-state-changed",
|
||||
data = new
|
||||
{
|
||||
userId = this.GetSystem<IGlobalConfigSystem>().GetUserId(),
|
||||
audio = value,
|
||||
video = _videoTog.isOn
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_audioStreamSender.enabled = value;
|
||||
SignalingMessageHelper.SendMessage(JsonConvert.SerializeObject(message));
|
||||
}
|
||||
|
||||
private void OnVideoTogValueChanged(bool value)
|
||||
{
|
||||
var message = new
|
||||
{
|
||||
type = "on-message",
|
||||
data = new
|
||||
{
|
||||
connectionId = this.GetSystem<IGlobalConfigSystem>().GetConnectionId(),
|
||||
message = new
|
||||
{
|
||||
type = "media-state-changed",
|
||||
data = new
|
||||
{
|
||||
userId = this.GetSystem<IGlobalConfigSystem>().GetUserId(),
|
||||
audio = _micTog.isOn,
|
||||
video = value
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_videoStreamSender.enabled = value;
|
||||
SignalingMessageHelper.SendMessage(JsonConvert.SerializeObject(message));
|
||||
}
|
||||
|
||||
private void OnRecordTogValueChanged(bool value)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnHangUpTogValueChanged()
|
||||
{
|
||||
this.GetSystem<IRenderStreamingSystem>().HangUp();
|
||||
this.GetSystem<IRenderStreamingSystem>().SetLocalVideoImage(null);
|
||||
this.GetSystem<IPanelSystem>().PopQueue<MainPanel>();
|
||||
this.GetSystem<IPanelSystem>().PushQueue<StartPanel>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当有用户断开连接时调用
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
@@ -225,6 +306,9 @@ namespace Script
|
||||
GameObject.FindObjectOfType<MessageChannel>().OnMediaStateChangeReceived -= OnMediaStateChangeReceived;
|
||||
GameObject.FindObjectOfType<MessageChannel>().OnUserInfoMessageReceived -= OnUserInfoMessageReceived;
|
||||
GameObject.FindObjectOfType<HostConnection>().OnParticipantDisconnected -= OnParticipantDisconnected;
|
||||
|
||||
foreach (var info in _meetingList.Values) _objectPool.Release(info.participant);
|
||||
_meetingList.Clear();
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
Reference in New Issue
Block a user