Пример #1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Welcome to chat room client! Follow the white rabbit...");

            int serverPort = 8888;

            if (args.Length > 0)
            {
                serverPort = int.Parse(args[0]);
            }

            _clientControl = new ClientControl();
            try
            {
                await _clientControl.Connect(serverPort);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Can't connect to chat server|Error={0}", ex.Message);
                Exit();
            }

            Console.WriteLine("Welcome to our chat server. Please provide a nickname");
            var nickname = Console.ReadLine();

            try
            {
                _clientControl.SendMessage(nickname);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Can't define your nickname|Error={0}", ex.Message);
                Exit();
            }

            var msg = string.Empty;

            do
            {
                msg = Console.ReadLine();

                if (msg == "/exit")
                {
                    break;
                }

                try
                {
                    _clientControl.SendMessage(msg);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Can't send your message|Error={0}", ex.Message);
                }
            } while (msg != "/exit");

            Console.WriteLine("See you later. Bye!");
            Thread.Sleep(3000);
            Exit();
        }
Пример #2
0
 public void Run()
 {
     dataClient.Run(dataHandeling.SendData());
     ClientView.ChouseFlight();
     ClientView.ChouseSeat();
     int flightChousen = ClientControl.ChouseFlight();
     int seatChousen = ClientControl.ChouseSeat();
     dataClient.Run(dataHandeling.FlightChousen($"{flightChousen}¶{seatChousen}");
     Console.ReadKey(true);
 }
Пример #3
0
        static void Main(string[] args)
        {
            ClientControl client = new ClientControl();

            client.Connect("127.0.0.1", 12345);
            string msg = Console.ReadLine();

            while (msg != "quit")
            {
                client.Send(msg);
                msg = Console.ReadLine();
            }
            Console.ReadKey();
        }
Пример #4
0
        static void Main(string[] args)
        {
            ClientControl clientControl = new ClientControl();

            clientControl.Connect("127.0.0.1", 12345);

            Console.WriteLine("请输入要发送的信息");
            string msg = null;

            while (msg != "quit")
            {
                clientControl.Send(msg);
                msg = Console.ReadLine();
            }
            Console.ReadKey();
        }