public void Update(int delta) { UpdatePingTime(delta); while (true) { ServerClass c = pool.HasSendMessages(); if (c == null) { break; } Queue <object> messages = c.messages; Socket client = pool.GetClientById(c.id); if (client != null) { while (messages.Count > 0) { mSendEvent.Invoke(client, messages.Dequeue()); } } } while (true) { ServerClass c = pool.HasReciveMessages(); if (c == null) { break; } Queue <object> messages = c.messages; Socket client = pool.GetClientById(c.id); if (client != null) { while (messages.Count > 0) { object obj = messages.Dequeue(); if (obj is PingClass) { pool.ResetPing(c.id); } else { OnEvent(obj); } } } } }
public ServerClass HasReciveMessages() { ServerClass ret = null; List <int> key = new List <int>(reciveMessPool.Keys); for (int i = 0; i < key.Count; i++) { if (reciveMessPool[key[i]].Count > 0) { ret = new ServerClass(); ret.id = key[i]; ret.messages = reciveMessPool[key[i]]; break; } } return(ret); }