Beispiel #1
0
        public static RemotingResponse ParseResponse(byte[] data)
        {
            var srcOffset = 0;

            var requestSequence      = ByteUtil.DecodeLong(data, srcOffset, out srcOffset);
            var requestCode          = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var requestType          = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var requestTime          = ByteUtil.DecodeDateTime(data, srcOffset, out srcOffset);
            var requestHeaderLength  = ByteUtil.DecodeInt(data, srcOffset, out srcOffset);
            var requestHeader        = HeaderUtil.DecodeHeader(data, srcOffset, out srcOffset);
            var responseCode         = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var responseTime         = ByteUtil.DecodeDateTime(data, srcOffset, out srcOffset);
            var responseHeaderLength = ByteUtil.DecodeInt(data, srcOffset, out srcOffset);
            var responseHeader       = HeaderUtil.DecodeHeader(data, srcOffset, out srcOffset);

            var responseBodyLength = data.Length - srcOffset;
            var responseBody       = new byte[responseBodyLength];

            Buffer.BlockCopy(data, srcOffset, responseBody, 0, responseBodyLength);

            return(new RemotingResponse(
                       requestType,
                       requestCode,
                       requestSequence,
                       requestTime,
                       responseCode,
                       responseBody,
                       responseTime,
                       requestHeader,
                       responseHeader));
        }
Beispiel #2
0
        public static RemotingServerMessage ParseRemotingServerMessage(byte[] data)
        {
            var srcOffset = 0;

            var id           = ByteUtil.DecodeString(data, srcOffset, out srcOffset);
            var type         = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var code         = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var createdTime  = ByteUtil.DecodeDateTime(data, srcOffset, out srcOffset);
            var headerLength = ByteUtil.DecodeInt(data, srcOffset, out srcOffset);
            var header       = HeaderUtil.DecodeHeader(data, srcOffset, out srcOffset);
            var bodyLength   = data.Length - srcOffset;
            var body         = new byte[bodyLength];

            Buffer.BlockCopy(data, srcOffset, body, 0, bodyLength);

            return(new RemotingServerMessage(type, id, code, body, createdTime, header));
        }
Beispiel #3
0
        public static RemotingRequest ParseRequest(byte[] data)
        {
            var srcOffset = 0;

            var id           = ByteUtil.DecodeString(data, srcOffset, out srcOffset);
            var sequence     = ByteUtil.DecodeLong(data, srcOffset, out srcOffset);
            var code         = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var type         = ByteUtil.DecodeShort(data, srcOffset, out srcOffset);
            var createdTime  = ByteUtil.DecodeDateTime(data, srcOffset, out srcOffset);
            var headerLength = ByteUtil.DecodeInt(data, srcOffset, out srcOffset);
            var header       = HeaderUtil.DecodeHeader(data, srcOffset, out srcOffset);
            var bodyLength   = data.Length - srcOffset;
            var body         = new byte[bodyLength];

            Buffer.BlockCopy(data, srcOffset, body, 0, bodyLength);

            return(new RemotingRequest(id, code, sequence, body, createdTime, header)
            {
                Type = type
            });
        }