Пример #1
0
        public void Run()
        {
            try
            {
                string message = "";
                while (!message.Equals("quit"))
                {
                    NetworkStream networkStream      = client.GetStream();
                    string        messageJson        = new BinaryReader(networkStream).ReadString();
                    Message       messageInformation = JsonConvert.DeserializeObject <Message>(messageJson);
                    message = messageInformation.Text;

                    //server.Broadcast(this, message);
                    server.ResponseToClient(this, messageInformation);
                    Console.WriteLine(message);
                }

                server.DisconnectClient(this);
                client.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }