using SC.XR.Unity; using System.Collections; using System.Collections.Generic; using UnityEngine; public class NetWorkLANManager : SingletonMono { public bool isServer = false; private client client; private server server; public Queue queueMsg; public Queue createDesMsg; private void Start() { client = this.GetComponent(); server = this.GetComponent(); queueMsg = new Queue(); createDesMsg = new Queue(); if (isServer) server.enabled = true; else client.enabled = true; } public void SendData(string msg) { if(isServer) { server.SendData(); } else { client.SendData(); } } public void RecMessage() { if(isServer) { if (server.queueRecMsg.Count < 1) return; // MessageData data = JsonConvert.DeserializeObject(server.queueRecMsg.Dequeue()); // 同步管理器 // SynchronizeManager.Instance.RecMessage(data); } else { if (client.queueRecMsg.Count < 1) return; // MessageData data = JsonConvert.DeserializeObject(client.queueRecMsg.Dequeue()); // 同步管理器 // SynchronizeManager.Instance.RecMessage(data); } } public void AddMsgData(bool isSyn, string msg) { if (isSyn) { if (queueMsg.Count > 10) { queueMsg.Dequeue(); } queueMsg.Enqueue(msg); } else createDesMsg.Enqueue(msg); } }