Ejemplo n.º 1
0
 public int ReadResponse(byte[] buff)
 {
     if (_reader._completed)
     {
         return(0);
     }
     return(_reader.Read(buff, 0, buff.Length));
 }
Ejemplo n.º 2
0
        internal protected override async Task <IList> ExecuteOeViaHttpClient <T, TResult>(QueryParameters <T, TResult> parameters)
        {
            WcfService.OdataWcfQuery result = await Program.Interceptor.Get(parameters.RequestUri);

            var responseReader = new ResponseReader(base.EdmModel);

            return(responseReader.Read <T>(result.Content).Cast <Object>().ToList());
        }
Ejemplo n.º 3
0
        public void ResponseReadWithoutPayloadTest()
        {
            var responseMessage = new NetMQMessage();

            responseMessage.Append((int)MessageType.Acknowledge);
            responseMessage.AppendEmptyFrame();

            var response = ResponseReader.Read(new NoEncryption(), responseMessage);

            Assert.AreEqual(MessageType.Acknowledge, response.Type);
            Assert.IsNull(response.Payload);
        }
Ejemplo n.º 4
0
        public void ResponseReadWithPayloadTest()
        {
            var responseMessage = new NetMQMessage();

            responseMessage.Append((int)MessageType.Error);
            responseMessage.Append(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ErrorCode.InvocationError)));

            var response = ResponseReader.Read <ErrorCode>(new NoEncryption(), responseMessage);

            Assert.AreEqual(MessageType.Error, response.Type);
            Assert.AreEqual(ErrorCode.InvocationError, response.Payload);
        }
Ejemplo n.º 5
0
        internal protected override async Task <IList> ExecuteOeViaHttpClient <T, TResult>(QueryParameters <T, TResult> parameters, long?resourceSetCount)
        {
            WcfService.OdataWcfQuery result = await Program.Interceptor.Get(parameters.RequestUri);

            var responseReader = new ResponseReader(base.EdmModel);

            IList fromOe;

            if (typeof(TResult) == typeof(Object))
            {
                fromOe = responseReader.Read <T>(result.Content).Cast <Object>().ToList();
            }
            else
            {
                fromOe = responseReader.Read <TResult>(result.Content).Cast <Object>().ToList();
            }

            if (resourceSetCount != null)
            {
                Xunit.Assert.Equal(resourceSetCount, responseReader.ResourceSet.Count);
            }

            return(fromOe);
        }
Ejemplo n.º 6
0
        private static Maybe <string> RequestPublicKey(RequestSocket requestSocket)
        {
            var request = RequestCreator.Create(new NoEncryption(), MessageType.RequestPublicKey);

            requestSocket.SendMultipartMessage(request);

            var responseMessage = requestSocket.ReceiveMultipartMessage();

            Maybe <string> response = null;

            ResponseReader.Read <string>(new NoEncryption(), new NoEncryption(), responseMessage)
            .Case((Response <string> publicKay) => response = new Maybe <string>(publicKay.Payload))
            .Fold(_ => response = new Nothing <string>());

            return(response);
        }
Ejemplo n.º 7
0
        private static void PlayWithConnection()
        {
            using var tcpClient = new TcpClient(host, port);
            var stream = tcpClient.GetStream();
            var buffer = new byte[512];

            using var requestWriter = new RequestWriter(stream);
            var responseReader = new ResponseReader(stream);

            stream.Read(buffer);
            var base64Salt = new ReadOnlySpan <byte>(buffer, 64, 44);

            var authRequest = new AuthRequest("user_test", "user_test", base64Salt)
            {
                SyncId = 1
            };

            requestWriter.Write(authRequest);
            var authResponse = responseReader.Read();

            //var selectRequest = new SelectRequest((uint)SystemSpaceE.Vspace, 0, IteratorE.All, 0U) {SyncId = 2};
            //requestWriter.Write(selectRequest);
            //var selectResponse = responseReader.Read();
        }