Encode() public static method

编码protobuf消息
public static Encode ( int id, object msg ) : byte[]
id int 消息id
msg object 消息object
return byte[]
Example #1
0
        public byte[] Encode(IMessage msg)
        {
            uint id = msgid_query_(msg.GetType());

            return((uint.MaxValue != id) ?
                   PBCodec.Encode(id, msg) :
                   null);
        }
Example #2
0
        public byte[] Encode(object msg)
        {
            int id = msgid_query_(msg.GetType());

            return((id > 0) ?
                   PBCodec.Encode(id, msg) :
                   null);
        }
Example #3
0
        private bool Build(IMessage msg, out byte[] data)
        {
            uint id = msgid_query_(msg.GetType());

            if (uint.MaxValue != id)
            {
                data = PBCodec.Encode(id, msg);
                return(null != data);
            }
            else
            {
                data = null;
                return(false);
            }
        }
Example #4
0
        private bool Build(object msg, out byte[] data)
        {
            int id = msgid_query_(msg.GetType());

            if (id > 0)
            {
                data = PBCodec.Encode(id, msg);
                return(null != data);
            }
            else
            {
                data = null;
                return(false);
            }
        }