// Update is called once per frame void Update() { if (!cManager.Connected) { return; } while (requests.Count > 0) { NetworkRequest packet = requests.Peek(); if (cManager.Send(packet.GetBytes())) { requests.Dequeue(); Debug.Log("Sent Request No. " + packet.GetID() + " [" + NetworkProtocolTable.Get(packet.GetID()).ToString() + "]"); } } counter++; if (counter == interval) { counter = 0; } foreach (NetworkResponse args in cManager.Read()) { bool status = false; int protocol_id = args.GetID(); // One-Time if (callbackList.ContainsKey(protocol_id)) { if (callbackList[protocol_id].Count > 0) { callbackList[protocol_id].Dequeue()(args); status = true; } } // Listen if (listenList.ContainsKey(protocol_id)) { if (listenList[protocol_id].Count > 0) { foreach (Callback callback in listenList[protocol_id]) { callback(args); } status = true; } } Debug.Log((status ? "Processed" : "Ignored") + " Response No. " + args.GetID() + " [" + NetworkProtocolTable.Get(args.GetID()).ToString() + "]"); } }