private void loginButton_Click(object sender, EventArgs e)
        {
            if (!ValidLoginInput())
                return;

            try {
                TcpClient client = new TcpClient();
                client.Connect(ipAddress, port);
                Connection conn = new Connection(client, true);

                conn.SendData(new AuthenticationRequest(GetUsername(), GetPassword()));

                AuthenticationResponse authentication = (AuthenticationResponse)conn.ReceiveData();

                if (authentication.Message == null) {
                    ConnectionsRepository.AddConnection(conn, true);
                    conn.DataTransfered += DataProcessor.ProcessData;
                    conn.InitializeDataListener();

                    this.Visible = false;
                    this.ShowInTaskbar = false;

                    GameForm game = new GameForm(conn);
                    conn.ShutdownRequest += ServerDown;
                    game.FormClosed += CloseClient;
                    game.Show();
                } else
                    noteLabel.Text = authentication.Message;

            } catch {
                noteLabel.Text = "No response from server.";
            }
        }
        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.");
                }
            }
        }