From 1c478006bc02f5f108642e5c2008f4ca0ab0ea87 Mon Sep 17 00:00:00 2001
From: chenxiangxue <910695411@qq.com>
Date: Tue, 27 Feb 2024 15:58:01 +0800
Subject: [PATCH] saccacac
---
Assets/Zion/Scripts/cxx/LoadManage.cs | 167 ++------------------------
1 file changed, 8 insertions(+), 159 deletions(-)
diff --git a/Assets/Zion/Scripts/cxx/LoadManage.cs b/Assets/Zion/Scripts/cxx/LoadManage.cs
index 703186e5..38fc6e8a 100644
--- a/Assets/Zion/Scripts/cxx/LoadManage.cs
+++ b/Assets/Zion/Scripts/cxx/LoadManage.cs
@@ -17,38 +17,10 @@ public class LoadManage : MonoBehaviour
///
[DisplayOnly]
public string currentRoomArea;
- ///
- /// 训练状态
- ///
- public static ProgramState programState = ProgramState.结束;
- ///
- /// 是否暂停
- ///
- public static bool isPause;
-
- ///
- /// 与RoomServer通信
- ///
[DisplayOnly]
public MyNetMQClient RSclient;
-
- public static Action registRequset;
- public static Action getusersRequset;
- public static Action createRoomRequset;
- public static Action getRoomsRequset;
- public static Action getownRoomsRequset;
- public static Action joinRoomRequset;
- public static Action joinsRequset;
- public static Action leaveRoomRequset;
- public static Action closeRoomRequset;
- public static Action playerInfoRequset;
- public static Action getroomusersRequset;
- public static Action send2roomRequset;
- public static Action send2userRequset;
- public static Action send2worldRequset;
-
-
+ public Action reciveData;
private void Awake()
{
Instance = this;
@@ -67,15 +39,15 @@ public class LoadManage : MonoBehaviour
Screen.sleepTimeout = SleepTimeout.NeverSleep;
string ip = "";
//配置
- File.ReadAllLines(Application.streamingAssetsPath + "/MainSetting.txt").ToList().ForEach(line =>
+ File.ReadAllLines(Application.streamingAssetsPath + "/MainSetting.txt").ToList().ForEach(line =>
{
- if(line.Trim(' ').StartsWith("serverIP="))
+ if (line.Trim(' ').StartsWith("serverIP="))
{
string[] tmps = line.Trim(' ').Split('=');
- ip= tmps[1];
+ ip = tmps[1];
}
});
- CreateRoomServerClient(string.Format("tcp://{0}:8889",ip), string.Format("tcp://{0}:8888",ip));
+ CreateRoomServerClient(string.Format("tcp://{0}:8889", ip), string.Format("tcp://{0}:8888", ip));
MyNetMQClient.instance._netMqListener.SubTopic("Room");
SceneManager.LoadScene("SampleScene");
}
@@ -112,64 +84,7 @@ public class LoadManage : MonoBehaviour
///
private void ReciveFromRoomServerInThread(st_Motions stS)
{
- if (stS.area == "Room")
- {
- //同步消息
- //if (programState == ProgramState.进行中)
- //{
- // if (stS.m_iOperaType == 10006)
- // {
- // //单值同步
- // int syncid = BitConverter.ToInt32(stS.m_sOperaData, 0);
- // if (LoadManage.Instance.me.SyncId != syncid)
- // {
- // int legth = BitConverter.ToInt32(stS.m_sOperaData, 4);
- // string id = Encoding.UTF8.GetString(stS.m_sOperaData, 8, legth);
- // if (OneValueSyncObject.OneAxisSyncObjectList.ContainsKey(id))
- // {
- // if (stS.m_sOperaData[9 + legth] == 0)
- // {
- // //无回调
- // OneValueSyncObject.OneAxisSyncObjectList[id].SetValue(8 + legth, stS.m_sOperaData);
- // }
- // else
- // {
- // //有回调
- // RSclient._netMqListener.AddToMono(stS);
- // }
- // }
- // }
- // }
- // else if (stS.m_iOperaType == 10007)
- // {
- // //坐标角度同步
- // int syncid = BitConverter.ToInt32(stS.m_sOperaData, 0);
- // if (LoadManage.Instance.me.SyncId != syncid)
- // {
- // int legth = BitConverter.ToInt32(stS.m_sOperaData, 4);
- // string id = Encoding.UTF8.GetString(stS.m_sOperaData, 8, legth);
- // if (FunctionSync_PositionRoate.positionRoateSyncObejctList.ContainsKey(id))
- // {
- // FunctionSync_PositionRoate.positionRoateSyncObejctList[id].SetValue(8 + legth, stS.m_sOperaData);
- // }
- // }
- // }
- // else if (stS.m_iOperaType == 61)
- // {
- // //心跳检测
- // //XinTiaoCheck();
- // }
- // else
- // {
- // RSclient._netMqListener.AddToMono(stS);
- // }
- //}
- }
- else if(stS.area == "System")
- {
- //系统消息
- RSclient._netMqListener.AddToMono(stS);
- }
+ RSclient._netMqListener.AddToMono(stS);
}
///
@@ -178,76 +93,10 @@ public class LoadManage : MonoBehaviour
///
public void ReciveFromRoomServerInMono(st_Motions stS)
{
-
-#if !UNITY_EDITOR
- try
+ if (reciveData != null)
{
-#endif
- string message = Encoding.UTF8.GetString(stS.m_sOperaData);
- string[] commands = message.Split(' ');
-
- if (commands.Length > 0)
- {
- //Debug.Log($"commands[0]===={commands[0]}");
- switch (commands[0])
- {
- case "regist":
- registRequset?.Invoke(commands[1]);
- break;
- case "getusers":
- getusersRequset?.Invoke(commands[1]);
- break;
- case "createroom":
- createRoomRequset?.Invoke(commands[1]);
- break;
- case "getrooms":
- getRoomsRequset?.Invoke(commands[1]);
- break;
- case "getownrooms":
- getownRoomsRequset?.Invoke(commands[1]);
- break;
- case "joinroom":
- joinRoomRequset?.Invoke(commands[1]);
- break;
- case "joins":
- joinsRequset?.Invoke(commands[1]);
- break;
- case "leaveroom":
- leaveRoomRequset?.Invoke(commands[1]);
- break;
- case "closeroom":
- closeRoomRequset?.Invoke(commands[1]);
- break;
- case "player":
- string[] data = commands[1].Split(';');
- if (data.Length == 3)
- {
- playerInfoRequset?.Invoke(ulong.Parse(data[0]), data[1], data[2]);
- }
- break;
- case "getroomusers":
- getroomusersRequset?.Invoke(commands[1]);
- break;
- case "send2room":
- send2roomRequset?.Invoke(commands[1]);
- break;
- case "send2user":
- send2userRequset?.Invoke(commands[1]);
- break;
- case "send2world":
- send2worldRequset?.Invoke(commands[1]);
- break;
- }
+ reciveData(stS.m_sOperaData);
}
-
-#if !UNITY_EDITOR
- }
- catch (Exception e)
- {
- Debug.LogError(e.Message);
- }
-#endif
-
}
private void OnDestroy()