Пример #1
0
 public static byte[] getBytes(Message message)
 {
     using( MemoryStream mem = new MemoryStream(1024)){
         BinaryFormatter binFormat = new BinaryFormatter();//创建二进制序列化器
         binFormat.Serialize(mem, message);
         return mem.GetBuffer();
        }
 }
Пример #2
0
 public void SendTextMessage(string text)
 {
     Message msg = new Message();
     msg.GUID = Guid.NewGuid().ToString();
     msg.message = text;
     byte[] bytes = MessageHelper.getBytes(msg);
     this.Send(bytes,0,bytes.Length);
 }