Esempio n. 1
0
 private Message ReceiveMessage()
 {
     try
     {
         return((Message)BFormatter.Deserialize(TcpClient.GetStream()));
     }
     catch (Exception)
     {
         Console.WriteLine(@"Disconnecting");
         Stop();
         return(null);
     }
 }
Esempio n. 2
0
        private Message ReceiveMessage(TcpClient client)
        {
            try
            {
                var message = (Message)BFormatter.Deserialize(client.GetStream());
                Console.WriteLine("Message received of type: " + message.Type);
                return(message);
            }
            catch (Exception)
            {
                client.GetStream().Close();
                client.Close();
            }

            return(null);
        }