private void Process()
        {
            while (ContinueProcess)
            {
                ClientHandler client = null;
                lock (ConnectionPool.SyncRoot)
                {
                    if (ConnectionPool.Count > 0)
                    {
                        client = ConnectionPool.Dequeue();
                    }
                }
                if (client != null)
                {
                    client.Process();              // Provoke client
                    // if client still connect, schedulor later processingle it
                    if (client.Alive)
                    {
                        ConnectionPool.Enqueue(client);
                    }

                    /*else
                     *      Console.WriteLine("dequeue client#{0}",client.m_Num );*/
                }

                Thread.Sleep(50);
            }
            //Console.WriteLine( "Client service ended" );
        }
Ejemplo n.º 2
0
        private void Process()
        {
            while (ContinueProcess)
            {
                ClientHandler client = null;
                lock (ConnectionPool.SyncRoot)
                {
                    if (ConnectionPool.Count > 0)
                    {
                        client = ConnectionPool.Dequeue();
                    }
                }
                if (client != null)
                {
                    client.Process();
                    if (client.StatusClient == Status.Waiting && !waitingPool.Contains(client))
                    {
                        waitingPool.Add(client);
                    }
                    if (client.StatusClient != Status.Guest && !verifiedPool.Contains(client))
                    {
                        verifiedPool.Add(client);
                    }

                    if (client.Alive)
                    {
                        lock (onlinePool)
                        {
                            if (!onlinePool.Contains(client))
                            {
                                onlinePool.Add(client);
                            }
                        }
                        ConnectionPool.Enqueue(client);
                    }
                    else
                    {
                        ClientDisconnect(client);
                        Console.WriteLine(client.Name + " disconnected");
                    }
                }

                Thread.Sleep(100);
            }
        }