public bool ContainsId(long id) { lock (Locker) { return(ClientIdSet.ContainsKey(id)); } }
private void ThreadProc() { while (IsRunning) { var msg = MsgQueue.Dequeue(); if (msg != null) { var id = msg.SenderConnection.RemoteUniqueIdentifier; if (MessageCallback != null) { MessageCallback(msg); } lock (Locker) { ClientIdSet[id]--; if (ClientIdSet[id] <= 0) { ClientIdSet.Remove(id); } } } Thread.Sleep(0); } }
public void AddMessage(NetIncomingMessage msg) { lock (Locker) { MsgQueue.Enqueue(msg); if (!ClientIdSet.ContainsKey(msg.SenderConnection.RemoteUniqueIdentifier)) { ClientIdSet[msg.SenderConnection.RemoteUniqueIdentifier] = 0; } ClientIdSet[msg.SenderConnection.RemoteUniqueIdentifier]++; } }
private InternRoot CreateProtocolInternRoot(Lifetime lifetime) { var root = new InternRoot(); root.RdId = RdId.Nil.Mix(ProtocolInternRootRdId); ClientIdSet.RdId = RdId.Nil.Mix(ClientIdSetRdId); Scheduler.InvokeOrQueue(() => { if (!lifetime.IsAlive) { return; } root.Bind(lifetime, this, ProtocolInternRootRdId); ClientIdSet.Bind(lifetime, this, ClientIdSetRdId); }); return(root); }