Exemple #1
0
 public bool SendMessage(Message msg)
 {
     try
     {
         byte[] buffer = Encoding.Unicode.GetBytes(msg.ToString());
         streamToServer.Write(buffer, 0, buffer.Length);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #2
0
 public bool SendMessage(Message msg, NetworkStream streamToClient)
 {
     string msgString = msg.ToString();
     byte[] buffer = Encoding.Unicode.GetBytes(msgString);
     try
     {
         streamToClient.Write(buffer, 0, buffer.Length);
         return true;
     }
     catch
     {
         return false;
         throw;
     }
 }