public void sendMessage(TcpClient client, Message message)
 {
     log.Info("Sending message : " + message.GetType().Name);
     byte[] messageWrapped = Util.Wrap(message);
     NetworkStream networkStream = client.GetStream();
     networkStream.Write(messageWrapped, 0, messageWrapped.Length);
 }
Exemple #2
0
 public static byte[] Wrap(Message kom)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(Message));
     StringBuilder sb = new StringBuilder();
     TextWriter textWriter = new StringWriter(sb);
     serializer.Serialize(textWriter, kom);
     System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
     byte[] tab = new byte[sb.Length - 1];
     tab = encoding.GetBytes(sb.ToString());
     textWriter.Close();
     return tab;
 }
 public void sendMessage(IPEndPoint ipEndPoint, Message message)
 {
     log.Info("Send message to: " + ipEndPoint.ToString());
     byte[] messageWrapped = Util.Wrap(message);
     sender.Send(messageWrapped, messageWrapped.Length, ipEndPoint);
 }