public void ListenForConnectionRequests()
        {
            Console.WriteLine("Listening for connection requests...");

            while (listener != null) {
                if (listener.Pending()) {
                    Connection conn = new Connection(listener.AcceptTcpClient(), false);
                    ConnectionsRepository.AddConnection(conn, false);
                    conn.DataTransfered += DataProcessor.ProcessData;
                    conn.InitializeDataListener();
                    Console.WriteLine("New connection accepted.");
                }
            }
        }
        public static void ProcessData(Connection conn, DataTransfer transfer)
        {
            if (conn == null || transfer == null)
                return;

            if (transfer is AuthenticationRequest) {
                AuthenticationRequest authenticationRequest = (AuthenticationRequest)transfer;
                PlayerAccount player = new PlayerAccount(authenticationRequest.Username, authenticationRequest.Password);
                string authenticationResponseMessage = AccountFileHandler.ReadAccount(player);

                if (authenticationResponseMessage == null)
                    PlayerHandler.AddPlayer(player);

                conn.SendData(new AuthenticationResponse(authenticationResponseMessage));
            }
        }
 public static void ProcessData(Connection conn, DataTransfer transfer)
 {
     if (conn == null || transfer == null)
         return;
 }
 public static void RemoveConnection(Connection connection)
 {
     connections.Remove(connection);
 }
 public static void AddConnection(Connection connection, bool client)
 {
     connections.Add(connection, client);
 }