Exemplo n.º 1
0
 private void Chat()
 {
     try
     {
         var netStream = ClientSocket.GetStream();
         var listen    = new BinaryReader(netStream);
         while (true)
         {
             try
             {
                 var message = listen.ReadString();
                 Server.OnMessageReceived(this, message);
             }
             catch (Exception ex)
             {
                 listen.Close();
                 netStream.Close();
                 Console.WriteLine(ex.Message);
                 return;
             }
         }
     }
     finally
     {
         Server.OnDisconnected(this);
     }
 }