示例#1
0
文件: message.cs 项目: bowen-xu/TCE
        //从二进制流中反序列化出对象RpcMessage
        public static RpcMessage unmarshall(Stream stream)
        {
            RpcMessage   m      = new RpcMessage();
            BinaryReader reader = new BinaryReader(stream);

            try {
                m.type      = RpcBinarySerializer.readByte(reader);
                m.sequence  = RpcBinarySerializer.readInt(reader);
                m.calltype  = RpcBinarySerializer.readByte(reader);
                m.ifidx     = RpcBinarySerializer.readShort(reader);
                m.opidx     = RpcBinarySerializer.readShort(reader);
                m.errcode   = RpcBinarySerializer.readInt(reader);
                m.paramsize = RpcBinarySerializer.readByte(reader);
                m.call_id   = RpcBinarySerializer.readShort(reader);
                if (m.extra.unmarshall(stream) == false)
                {
                    return(null);
                }
                m.paramstream = reader.ReadBytes((int)(stream.Length - stream.Position));
            }
            catch (Exception e) {
                RpcCommunicator.instance().logger.error(e.ToString());
                m = null;
            }
            return(m);
        }
示例#2
0
文件: extradata.cs 项目: demonxjj/TCE
        // cha ,java 里面有个bug啊,计算datasize有问题,回过头去改一下(python,...其他有没有问题啊,查查!)
        public int datasize()
        {
            int size = 0;
            //string key, val;
            UTF8Encoding utf8 = new UTF8Encoding();

            foreach (KeyValuePair <string, string> kv in _props)
            {
                size += RpcBinarySerializer.getByteCount(kv.Key) + RpcBinarySerializer.getByteCount(kv.Value);
            }
            return(size);
        }
示例#3
0
文件: extradata.cs 项目: demonxjj/TCE
 public bool marshall(Stream d)
 {
     try{
         BinaryWriter writer = new BinaryWriter(d);
         if (_props == null)
         {
             _props = new Dictionary <string, string>();
         }
         RpcBinarySerializer.writeInt(_props.Count, writer);
         foreach (KeyValuePair <string, string> kv in _props)
         {
             RpcBinarySerializer.writeString(kv.Key, writer);
             RpcBinarySerializer.writeString(kv.Value, writer);
         }
     }
     catch (Exception e) {
         return(false);
     }
     return(true);
 }
示例#4
0
文件: message.cs 项目: bowen-xu/TCE
        //刚才出去吃麦,看到一只dog在贴单子,一过去,车开走了,那个沮丧的样子哦,还一直呆在那里与正拍摄的我进行对视
        // 车子,单子,票子奋斗的dog
        public Stream marshall()
        {
            // to be continue..
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            RpcBinarySerializer.writeByte((byte)RpcConstValue.MSGTYPE_RPC, writer);
            RpcBinarySerializer.writeInt(this.sequence, writer);
            RpcBinarySerializer.writeByte((byte)this.calltype, writer);
            RpcBinarySerializer.writeShort((short)this.ifidx, writer);
            RpcBinarySerializer.writeShort((short)this.opidx, writer);
            RpcBinarySerializer.writeInt(this.errcode, writer);
            RpcBinarySerializer.writeByte((byte)this.paramsize, writer);
            RpcBinarySerializer.writeShort((short)this.call_id, writer);
            this.extra.marshall(stream);
            if (this.paramstream != null)
            {
                writer.Write(this.paramstream);
            }
            return(stream);
        }
示例#5
0
文件: extradata.cs 项目: demonxjj/TCE
        //BinaryReader 以 Little-Endian 格式读取此数据类型。
        // Network Order is Big-Endian
        public bool unmarshall(Stream d)
        {
            try{
                BinaryReader reader = new BinaryReader(d);
                int          size   = 0;

                size = RpcBinarySerializer.readInt(reader);
                string key, val;
                //byte[] bytes;
                //int len = 0;

                for (int n = 0; n < size; n++)
                {
                    key = RpcBinarySerializer.readString(reader);
                    val = RpcBinarySerializer.readString(reader);
                    _props.Add(key, val);
                }
            }catch (Exception e) {
                RpcCommunicator.instance().getLogger().error(e.ToString());
                return(false);
            }
            return(true);
        }