/// <summary> /// Initialise the lobby for a guest. /// </summary> /// <param name="username">The user's identifier.</param> /// <param name="address">The ip address.</param> private async Task InitialiseGuest(string username, string address) { // Connect to host _lobby = new Lobby(); try { await _lobby.ConnectAsync(address, username); } catch (Exception e) { Window window = new MainWindow(); window.Show(); this.Close(); MessageBox.Show("Connection refused!", "HideNSeek", MessageBoxButton.OK, MessageBoxImage.Error); #if DEBUG Console.WriteLine(e.Message); #endif } // Configure player listbox lBoxPlayers.Items.Add($"YOU: {username}"); // _host.Lobby.PlayerConnected += (Player player) => { lBoxPlayers.Items.Add(player.PlayerName); }; // Configure buttons btnDisconnect.Content = "Disconnect"; btnStart.IsEnabled = false; // Configure address label lbAddress.Content = address; }