public override void Init() { buffer = new ByteBuffer(cBufferSize); // 由于无法控制socket对缓冲区的写入过程, 所以无法进行动态扩容, 直接将初始值设置的大一些 tempBuffer = new ByteBuffer(cBufferSize); sendBuffer = new ByteBuffer(cBufferSize); recvPool = new NetPool(); sendPool = new NetPool(); timeoutPacket.Clear(); recvThread = new Thread(new ThreadStart(OnSocketReceive)); recvThread.Name = "DIDANetmanager_Recv"; recvThread.IsBackground = false; recvThread.Priority = System.Threading.ThreadPriority.Normal; recvThread.Start(); sendThread = new Thread(new ThreadStart(OnSocketSend)); sendThread.Name = "DIDANetmanager_Send"; sendThread.IsBackground = false; sendThread.Priority = System.Threading.ThreadPriority.Normal; sendThread.Start(); Volatile.Write(ref isConnected, false); hasLogined = false; }
public void Init() { lengthEncode = LengthEncoding.Encode; lengthDecode = LengthEncoding.Decode; messageEncode = MessageEncoding.Encode; messageDecode = MessageEncoding.Decode; recvPool = new NetPool(); sendPool = new NetPool(); }
protected override void OnLoadFinish() { pool = new NetPool(); logList = new List <NetMetaInfo>(); logTemplate = panel.transform.Find("ScrollView/Viewport/Content/ItemTemplate").gameObject; scrollRect = panel.transform.Find("ScrollView").GetComponent <ScrollRect>(); logTemplate.SetActive(false); btnClear = panel.transform.Find("BtnClear").gameObject; btnClear.GetComponent <Button>().onClick.AddListener(() => { ClearAllLogs(); }); btnStart = panel.transform.Find("BtnStart").gameObject; btnStart.GetComponent <Button>().onClick.AddListener(() => { StartLog(); }); btnStop = panel.transform.Find("BtnStop").gameObject; btnStop.GetComponent <Button>().onClick.AddListener(() => { StopLog(); }); btnCopy = panel.transform.Find("BtnCopy").GetComponent <Button>(); btnCopy.onClick.AddListener(() => { StringBuilder builder = new StringBuilder(); foreach (var info in logList) { builder.AppendLine(GetPrintStr(info)); } EditorInterface.CopyToClipboard(builder.ToString()); }); recording = panel.transform.Find("Recording").GetComponent <Image>(); this.cache.AddTemplate(TEMPLATE_ITEM_STR, logTemplate); }