Ejemplo n.º 1
0
        public void Start()
        {
            _client = new QuicClient();

            try
            {
                _client.Connect("127.0.0.1", 8880);

                _stream = _client.CreateStream();
                Thread t = new Thread(new ThreadStart(ReceiveMessage));

                t.Start();

                while (true)
                {
                    Console.Write("# Your message: ");
                    string input             = Console.ReadLine();
                    string str               = _username + ": " + input;
                    int    currentLineCursor = Console.CursorTop - 1;
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    Console.Write(new string(' ', Console.WindowWidth));
                    Console.SetCursorPosition(0, currentLineCursor);
                    Console.WriteLine("You: " + input);

                    byte[] b = System.Text.Encoding.UTF8.GetBytes(str);
                    _stream.Write(b, 0, b.Length);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Couldn't connect to the server port {port}");
                Console.WriteLine(e.Message);
            }
        }