Esempio n. 1
0
        public static RpcResponse DeserializeResponse(Stream resStream)
        {
            RpcResponse rsp = null;

            try
            {
                var deserializer = new Deserializer(resStream);
                var classDef     = deserializer.ReadValue() as ClassDef;
                if (!Constants.RpcResponseJavaFullName.Equals(classDef.Name))
                {
                    throw new HessianException($"unknown class :{classDef.Name}");
                }

                rsp = HessianObjectHelper.GetRealObjectValue(deserializer, deserializer.ReadValue()) as RpcResponse;
            }
            catch (EndOfStreamException)
            {
                //没有数据可读了
            }
            catch (Exception)
            {
                //TODO: do something?
            }

            return(rsp);
        }
Esempio n. 2
0
        public static RpcRequest DeserializeRequest(Stream stream)
        {
            RpcRequest request = null;

            try
            {
                var deserializer = new Deserializer(stream);
                var classDef     = deserializer.ReadValue() as ClassDef;
                if (!Constants.RpcRequestJavaFullName.Equals(classDef.Name))
                {
                    throw  new HessianException($"unknown class :{classDef.Name}");
                }
                request = HessianObjectHelper.GetRealObjectValue(deserializer, deserializer.ReadValue()) as RpcRequest;
            }
            catch (EndOfStreamException)
            {
                //没有数据可读了
            }
            return(request);
        }