readInt() public static method

public static readInt ( BinaryReader reader ) : int
reader System.IO.BinaryReader
return int
Beispiel #1
0
        //从二进制流中反序列化出对象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);
        }
Beispiel #2
0
        //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);
        }