Exemplo n.º 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");
            }
        }
Exemplo n.º 2
0
 public void AddLoggedInUser(string login, ClientEndpoint clientEndpoint)
 {
     this.clients.Add(login, clientEndpoint);
 }
Exemplo n.º 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");
            }
        }
Exemplo n.º 4
0
 public void QueueClientForRemoval(ClientEndpoint clientEndpoint)
 {
     this.unusedClients.Add(clientEndpoint.Login);
 }
Exemplo n.º 5
0
 public void AddLoggedInUser(string login, ClientEndpoint clientEndpoint)
 {
     this.clients.Add(login, clientEndpoint);
 }
Exemplo n.º 6
0
 public void QueueClientForRemoval(ClientEndpoint clientEndpoint)
 {
     this.unusedClients.Add(clientEndpoint.Login);
 }