Esempio n. 1
0
        public static byte[] EncodeMsg(Thrift.Protocol.TBase reqMsg)
        {
            var tmem  = new Thrift.Transport.TMemoryBuffer();
            var proto = new Thrift.Protocol.TBinaryProtocol(tmem);

            //proto.WriteMessageBegin(new Thrift.Protocol.TMessage("ff::RegisterToBrokerReq", Thrift.Protocol.TMessageType.Call, 0));
            reqMsg.Write(proto);
            //proto.WriteMessageEnd();
            byte[] byteData = tmem.GetBuffer();
            return(byteData);
        }
Esempio n. 2
0
 /// <summary>
 /// Gets bytes that represents the current object.
 /// </summary>
 /// <returns></returns>
 public static byte[] GetBytes <T>(T tobj) where T : TAbstractBase
 {
     using (var trans = new Thrift.Transport.TMemoryBuffer())
     {
         using (var oprot = new Thrift.Protocol.TBinaryProtocol(trans))
         {
             tobj.Write(oprot);
             return(trans.GetBuffer());
         }
     }
 }
Esempio n. 3
0
        public static string encodeMsg <T>(T reqMsg) where T : Thrift.Protocol.TBase
        {
            var tmem  = new Thrift.Transport.TMemoryBuffer();
            var proto = new Thrift.Protocol.TBinaryProtocol(tmem);

            //proto.WriteMessageBegin(new Thrift.Protocol.TMessage("ff::RegisterToBrokerReq", Thrift.Protocol.TMessageType.Call, 0));
            reqMsg.Write(proto);
            //proto.WriteMessageEnd();
            byte[] byteData = tmem.GetBuffer();
            string strRet   = System.Text.Encoding.UTF8.GetString(byteData, 0, byteData.Length);

            return(strRet);
        }