// 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(); if (packet.GetID() != 211) { Debug.Log("CW: Sent Request No. " + packet.GetID() + " [" + NetworkProtocolTable.Get(packet.GetID()).ToString() + "]"); } } } counter++; if (counter == interval) { //Debug.Log ("checking response buffer... (+50)"); 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; } } if (args.GetID() != 211) { Debug.Log((status ? "Processed" : "Ignored") + " Response No. " + args.GetID() + " [" + NetworkProtocolTable.Get(args.GetID()).ToString() + "]"); } } }