Пример #1
0
        private async Task Connect()
        {
            ChatRoom = new ChatroomViewModel();
            int socketPort = 0;
            var validPort  = int.TryParse(Port, out socketPort);

            if (!validPort)
            {
                DisplayError("Please provide a valid port.");
                return;
            }

            if (String.IsNullOrWhiteSpace(Address))
            {
                DisplayError("Please provide a valid address.");
                return;
            }

            if (String.IsNullOrWhiteSpace(Username))
            {
                DisplayError("Please provide a username.");
                return;
            }

            ChatRoom.Clear();
            await Task.Run(() => ChatRoom.Connect(Username, Address, socketPort));
        }
Пример #2
0
        public MainWindowViewModel()
        {
            ChatRoom = new ChatroomViewModel();

            ConnectCommand    = new AsyncCommand(Connect, CanConnect);
            DisconnectCommand = new AsyncCommand(Disconnect, CanDisconnect);
            SendCommand       = new AsyncCommand(Send, CanSend);
        }