/// <summary>
        /// establish a connection to the chat server
        /// </summary>
        /// <returns></returns>
        private async Task Connect()
        {
            ToggleBlockConnectionCommands(false);

            var character = SimpleIoc.Default.GetInstance <CharacterViewModel>().Character;
            var settings  = settingsViewModel.Setting;

            Username = SimpleIoc.Default.GetInstance <CharacterViewModel>().SelectedCharacter.Name;

            if (string.IsNullOrWhiteSpace(Username))
            {
                Username = character.Name != "" ? character.Name : "User" + new Random().Next(1000, 9999);
            }

            UserType  = (SimpleIoc.Default.GetInstance <SettingsViewModel>().Setting.GameMasterMode) ? UserType.GameMaster : UserType.Player;
            Address   = SimpleIoc.Default.GetInstance <SettingsViewModel>().Setting.ServerAddress;
            Port      = SimpleIoc.Default.GetInstance <SettingsViewModel>().Setting.ServerPort;
            ColorCode = (SimpleIoc.Default.GetInstance <SettingsViewModel>().Setting.GameMasterMode) ? "Red" : "Black";

            var validIp = IPAddress.TryParse(Address, out IPAddress ipAddress);

            if (!validIp)
            {
                try
                {
                    ipAddress = Dns.GetHostAddresses(Address)[0];
                }
                catch
                {
                    DisplayError("Server Adresse leer oder ungültig, bitte in den Einstellungen überprüfen.");
                    return;
                }
            }

            UserModel user = new(Username, UserType, settings.UserIdentifier);

            var validPort = int.TryParse(Port, out int socketPort);

            if (!validPort)
            {
                DisplayError("Gibt bitte einen gültigen Server Port an");
                return;
            }

            if (string.IsNullOrWhiteSpace(Address))
            {
                DisplayError("Gib bitte eine gültige Server Adresse an");
                return;
            }

            if (string.IsNullOrWhiteSpace(Username))
            {
                DisplayError("Gib bitte einen Namen an");
                return;
            }

            ChatRoom.Clear();

            await Task.Run(() => ChatRoom.Connect(Address, socketPort));

            settingsViewModel.AllowEdit = false;
            ToggleBlockConnectionCommands(true);
        }