Exemple #1
0
 private Message ReceiveMessage()
 {
     try
     {
         return((Message)BFormatter.Deserialize(TcpClient.GetStream()));
     }
     catch (Exception)
     {
         Console.WriteLine(@"Disconnecting");
         Stop();
         return(null);
     }
 }
Exemple #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);
        }
Exemple #3
0
 private void SendMessage(TcpClient client, Message message)
 {
     BFormatter.Serialize(client.GetStream(), message);
     Console.WriteLine("Message sent of type: " + message.Type);
 }
Exemple #4
0
 private void SendMessage(Message message) => BFormatter.Serialize(TcpClient.GetStream(), message);