예제 #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;
     }
 }
예제 #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;
     }
 }