123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- using System;
- using ShadowStudio.Model;
- using Studio.Scripts.HttpMessage;
- /********************************************************************************
- ** Company: YC
- ** auth: CaoTing
- ** date: 2021\5
- ** desc: 处理home room事务
- *******************************************************************************/
- namespace Studio.Scripts
- {
- public class HomeProxy : UnitySingleton<HomeProxy>
- {
- public Action<int> CreateRoomAction;
- public Action<int> DeleteRoomAction;
- public Action UpdateSettingsAction;
- public Action<MySetting> GetSettingsAction;
- /// <summary>
- /// 文件存储地址获取
- /// </summary>
- public Action<string> GetFileAddressAction;
- /// <summary>
- /// 获取资源列表
- /// </summary>
- public Action<List<ArtInfo>> GetArtListAction;
- /// <summary>
- /// 获取资源
- /// </summary>
- public Action<ArtInfo> GetArtDetailAction;
- /// <summary>
- /// 搜索资源列表
- /// </summary>
- public Action<List<ArtInfo>> SearchArtListAction;
- /// <summary>
- /// 搜索资源无资源
- /// </summary>
- public Action NoArtReturnAction;
- /// <summary>
- /// ArtInfoMgr 专用的一个回调
- /// </summary>
- private Action<ArtInfo> _artDetailAction;
- private bool _isCreatePrivateRomm = true;
- public bool IsCreatePrivateRoom { get => _isCreatePrivateRomm; }
- /// <summary>
- /// 资源列表
- /// </summary>
- public List<ArtInfo> ArtList { get => _artList; }
- /// <summary>
- /// 资源列表
- /// </summary>
- private List<ArtInfo> _artList ;
- private MySetting _mySetting;
- public MySetting my_MySetting
- {
- get => _mySetting;
- }
- public void IsOpenPrivateOrPublicRoom(bool isPrivate)
- {
- _isCreatePrivateRomm = isPrivate;
- }
- private void Start()
- {
- _artList = new List<ArtInfo>();
- }
- public void GetModelList()
- {
- Studio.Scripts.HomeProxy.Instance.RequestFileAddress();
- }
- /// <summary>
- /// 根据资源id获取资源具体信息
- /// </summary>
- /// <param name="artID"></param>
- /// <param name="artInfoAction"></param>
- public void GetArtInfoDetailByArtID(string artID,Action<ArtInfo> artInfoAction)
- {
- RequestArtDetail(artID);
- _artDetailAction = artInfoAction;
- GetArtDetailAction += _artDetailAction;
- }
- #region 请求服务器数据
- /// <summary>
- /// 修改我的设置
- /// </summary>
- public void RequestUpdateSettings(bool isOpenCamera, bool isOpenMic, RatioType ratioType , FpsType fpsType)
- {
- NetWorkHeaders.Instance.UpdateSettings(UserInfo.User_Token,isOpenCamera,isOpenMic,ratioType,fpsType);
- }
- /// <summary>
- /// 修改我的设置
- /// </summary>
- public void RequestUpdateSettings(int fmss)
- {
- NetWorkHeaders.Instance.UpdateSettings(UserInfo.User_Token, fmss);
- }
- /// <summary>
- /// 获取房间设置
- /// </summary>
- public void RequestGetSettings()
- {
- NetWorkHeaders.Instance.GetSettings(UserInfo.User_Token);
- }
- /// <summary>
- /// 创建房间
- /// </summary>
- /// <param name="roomType">1:个人 2:公开</param>
- /// <param name="roomName">房间名</param>
- /// <param name="roomExplain">房间信息说明</param>
- /// <param name="roomPassword">房间密码</param>
- /// <param name="publicRoomType">公开房间类型 1 是只能浏览 2是 全功能</param>
- public void RequestCreateRoom(int roomType, string roomName = "", string roomExplain = "", string roomPassword = "", int publicRoomType = 1,int roomMaxNum=3)
- {
- NetWorkHeaders.Instance.CreateRoom(UserInfo.User_Token, roomType, roomName, roomExplain, roomPassword, roomMaxNum, publicRoomType);
- }
- public void RequestCreateRoom(string roomName = "", string roomExplain = "", string roomPassword = "", int publicRoomType = 1, int roomMaxNum = 3)
- {
- NetWorkHeaders.Instance.CreateRoom(UserInfo.User_Token, _isCreatePrivateRomm?1:2, roomName, roomExplain, roomPassword, _isCreatePrivateRomm?1: roomMaxNum, publicRoomType);
- }
- /// <summary>
- /// 删除房间
- /// </summary>
- /// <param name="roomID"></param>
- public void RequestDeleteRoom(int roomID)
- {
- NetWorkHeaders.Instance.DeleteRoom(roomID,UserInfo.User_Token);
- }
- /// <summary>
- /// 文件存储地址获取
- /// </summary>
- public void RequestFileAddress()
- {
- NetWorkHeaders.Instance.GetFileAddress(UserInfo.User_Token);
- }
- /// <summary>
- /// 获取资源列表
- /// </summary>
- /// <param name="searchInput"></param>
- public void RequestGetArtList(int artType)
- {
- NetWorkHeaders.Instance.GetArtList(UserInfo.User_Token, artType);
- }
- /// <summary>
- /// 获取资源详情
- /// </summary>
- /// <param name="artID"></param>
- public void RequestArtDetail(string artID )
- {
- NetWorkHeaders.Instance.GetDetailAir(UserInfo.User_Token, artID);
- }
- /// <summary>
- /// 搜索资源列表
- /// </summary>
- /// <param name="artType"></param>
- /// <param name="fileType"></param>
- /// <param name="keywords"></param>
- public void RequestSearchArtList(int artType, int fileType, string keywords = "")
- {
- NetWorkHeaders.Instance.SearchArtList(UserInfo.User_Token, artType, fileType, keywords);
- }
- #endregion
- #region http respond
- /// <summary>
- /// 更新设置
- /// </summary>
- /// <param name="updateRoomCallBackMessage"></param>
- public void UpdateSettingsHandler(UpdateSettingsCallBackMessage updateRoomCallBackMessage)
- {
- UpdateSettingsCallBackData data = updateRoomCallBackMessage.data;
- if (UpdateSettingsAction != null)
- {
- UpdateSettingsAction();
- }
- }
- /// <summary>
- /// 获取设置
- /// </summary>
- /// <param name="getSettingsCallBackMessage"></param>
- public void GetSettingsHandler(GetSettingsCallBackMessage getSettingsCallBackMessage)
- {
- GetSettingsCallBackData data = getSettingsCallBackMessage.data;
- _mySetting = new MySetting(data.camera, data.mic, (int)data.ratio, (int)data.fps, (int)data.isActivate,(int)data.fmss);
- GetSettingsAction?.Invoke(_mySetting);
- }
- /// <summary>
- /// 创建房间
- /// </summary>
- /// <param name="createRoomCallBackMessage"></param>
- public void CreateRoomHandler(CreateRoomCallBackMessage createRoomCallBackMessage)
- {
- CreateRoomCallBackData data = createRoomCallBackMessage.data;
- if (CreateRoomAction != null)
- {
- CreateRoomAction(data.roomID);
- }
- }
- /// <summary>
- /// 删除房间
- /// </summary>
- /// <param name="deleteRoomCallBackMessage"></param>
- public void DeleteRoomHandler(DeleteRoomCallBackMessage deleteRoomCallBackMessage)
- {
- DeleteRoomCallBackData data = deleteRoomCallBackMessage.data;
- if (DeleteRoomAction != null)
- {
- DeleteRoomAction(data.roomID);
- }
- }
- /// <summary>
- /// 文件存储地址回调
- /// </summary>
- /// <param name="fileAddressCallBackMessage"></param>
- public void GetFileAddressHandler(FileAddressCallBackMessage fileAddressCallBackMessage)
- {
- ResourcesManager.ArtServerPath = fileAddressCallBackMessage.data.fileAddress;
- //不知道为什么是7,老项目就是7
- for (int i = 0; i < 7; i++)
- {
- RequestGetArtList(i);
- }
- if (GetFileAddressAction != null)
- {
- GetFileAddressAction(fileAddressCallBackMessage.data.fileAddress);
- }
- }
- /// <summary>
- /// 获取资源列表
- /// </summary>
- /// <param name="getArtListCallBackMessage"></param>
- public void GetArtListHandler(GetArtListCallBackMessage getArtListCallBackMessage)
- {
- if (getArtListCallBackMessage.data.result != null && getArtListCallBackMessage.data.result.Count > 0)
- {
- _artList.AddRange(this.GetArtInfoListByArtCallBackDatas(getArtListCallBackMessage.data.result));
- CommonMethod.SetArtInfoList(_artList);
- if (GetArtListAction != null)
- {
- GetArtListAction(_artList);
- }
- }
-
- }
- /// <summary>
- /// 获取资源详情回调
- /// </summary>
- /// <param name="getArtDetailCallBackMessage"></param>
- public void GetArtDetailHandler(GetArtDetailCallBackMessage getArtDetailCallBackMessage)
- {
- ArtCallBackData data = getArtDetailCallBackMessage.data;
- ArtInfo artInfo =this.GetArtInfoByArtCallBackData(data);
- if (GetArtDetailAction != null)
- {
- GetArtDetailAction(artInfo);
- if (Array.IndexOf(GetArtDetailAction.GetInvocationList(), _artDetailAction) >= 0)
- {
- //GetArtDetailAction -= _artDetailAction;
- }
- }
- }
- /// <summary>
- /// 搜索资源列表的回调
- /// </summary>
- /// <param name="searchArtListCallBackMessage"></param>
- public void SearchArtListHandler(SearchArtListCallBackMessage searchArtListCallBackMessage)
- {
- if (searchArtListCallBackMessage.data.list != null && searchArtListCallBackMessage.data.list.Count > 0)
- {
- SearchArtListAction?.Invoke(this.GetArtInfoListByArtCallBackDatas(searchArtListCallBackMessage.data.list));
- }
- }
- #endregion
- /// <summary>
- /// 错误信息汇总
- /// </summary>
- /// <param name="messageType"></param>
- /// <param name="code"></param>
- /// <param name="codeMessage"></param>
- /// <param name="loginNum"></param>
- public void HomeErrorHandler(MessageType messageType, int code, string codeMessage)
- {
- if (code == 5018)
- {
- NoArtReturnAction?.Invoke();
- }
- }
- }
- }
|