예제 #1
0
        public KRPCData unPackRPCData(Byte[] bytes)
        {

            var ba = new BinaryReader(new MemoryStream(bytes));

            var rpcData = new KRPCData();

            var len = ba.ReadInt32();

            if (len != 0)
            {

                var ba_request = ba.ReadBytes(len);
                rpcData.request = unPackRequests(ba_request);

            }

            len = ba.ReadInt32();
            if (len != 0)
            {

                var ba_response = ba.ReadBytes(len);
                rpcData.response = unPackResponse(ba_response);

            }

            return rpcData;

        }
예제 #2
0
        public Byte[] packRPCData(KRPCData rpcData)
        {

            var ba = new BinaryWriter(new MemoryStream());

            if (null == rpcData.request)
            {
                ba.Write((int)0);
            }
            else
            {
                var ba_request = packRequests(rpcData.request);
                ba.Write((int)ba_request.Length);
                ba.Write(ba_request, 0, ba_request.Length);
            }



            if (null == rpcData.response)
            {
                ba.Write((int)0);
            }
            else
            {
                var ba_response = packResponse(rpcData.response);
                ba.Write((int)ba_response.Length);
                ba.Write(ba_response, 0, ba_response.Length);
            }

            var bytes = new Byte[ba.BaseStream.Length];
            ba.BaseStream.Position = 0;
            ba.BaseStream.Read(bytes, 0, bytes.Length);
            
            return bytes;
        }