示例#1
0
        private void Listen()
        {
            TcpListener tcpListener = null;

            try
            {
                tcpListener = new TcpListener(IPAddress.Any, this.Port);
                tcpListener.Start();

                while (this.continueToListen)
                {
                    if (tcpListener.Pending())
                    {
                        var tcpClient      = tcpListener.AcceptTcpClient();
                        var clientEndpoint = new ClientEndpoint(this, this.dataContext, tcpClient);
                        clientEndpoint.ProcessPendingConnection();
                    }
                    else
                    {
                        // Processing current connections
                        foreach (var de in this.clients)
                        {
                            de.Value.ProcessCurrentConnection();
                        }

                        this.FreeClientsQueuedForRemoval();

                        // cleanupRooms(); // Free unocupied rooms - deprecated because of saving room params (password)
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString);
            }
            finally
            {
                if (tcpListener != null)
                {
                    tcpListener.Stop();
                }

                Log.Info("Listening finished");
            }
        }
示例#2
0
 public void AddLoggedInUser(string login, ClientEndpoint clientEndpoint)
 {
     this.clients.Add(login, clientEndpoint);
 }
示例#3
0
        private void Listen()
        {
            TcpListener tcpListener = null;
            try
            {
                tcpListener = new TcpListener(IPAddress.Any, this.Port);
                tcpListener.Start();

                while (this.continueToListen)
                {
                    if (tcpListener.Pending())
                    {
                        var tcpClient = tcpListener.AcceptTcpClient();
                        var clientEndpoint = new ClientEndpoint(this, this.dataContext, tcpClient);
                        clientEndpoint.ProcessPendingConnection();
                    }
                    else
                    {
                        // Processing current connections
                        foreach (var de in this.clients)
                        {
                            de.Value.ProcessCurrentConnection();
                        }

                        this.FreeClientsQueuedForRemoval();

                        // cleanupRooms(); // Free unocupied rooms - deprecated because of saving room params (password)
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString);
            }
            finally
            {
                if (tcpListener != null)
                {
                    tcpListener.Stop();
                }

                Log.Info("Listening finished");
            }
        }
示例#4
0
 public void QueueClientForRemoval(ClientEndpoint clientEndpoint)
 {
     this.unusedClients.Add(clientEndpoint.Login);
 }
示例#5
0
 public void AddLoggedInUser(string login, ClientEndpoint clientEndpoint)
 {
     this.clients.Add(login, clientEndpoint);
 }
示例#6
0
 public void QueueClientForRemoval(ClientEndpoint clientEndpoint)
 {
     this.unusedClients.Add(clientEndpoint.Login);
 }