Example #1
0
        public static async Task Run()
        {
            AuthenticationHeaderValue authHeaderValue = AuthenticationHeaderValue.Parse("Basic R2VrY3RlazpXZWxjMG1lIQ==");
            RpcClient   client   = new RpcClient(new Uri("http://localhost:62390/RpcApi/"), authHeaderValue);
            RpcRequest  request  = new RpcRequest("Id1", "CharacterCount", "Test");
            RpcResponse response = await client.SendRequestAsync(request, "Strings");

            List <RpcRequest> requests = new List <RpcRequest>
            {
                request,
                new RpcRequest("id2", "CharacterCount", "Test2"),
                new RpcRequest("id3", "CharacterCount", "Test23")
            };
            List <RpcResponse> bulkResponse = await client.SendBulkRequestAsync(requests, "Strings");

            IntegerFromSpace responseValue = response.GetResult <IntegerFromSpace>();

            if (responseValue == null)
            {
                Console.WriteLine("null");
            }
            else
            {
                Console.WriteLine(responseValue.Test);
            }
        }
Example #2
0
        public static async Task Run()
        {
            AuthenticationHeaderValue authHeaderValue = AuthenticationHeaderValue.Parse("Basic R2VrY3RlazpXZWxjMG1lIQ==");
            RpcClient   client   = new RpcClient(new Uri("http://localhost:62390/RpcApi/"), authHeaderValue);
            RpcRequest  request  = RpcRequest.WithParameterList("CharacterCount", new[] { "Test" }, "Id1");
            RpcResponse response = await client.SendRequestAsync(request, "Strings");

            List <RpcRequest> requests = new List <RpcRequest>
            {
                request,
                RpcRequest.WithParameterList("CharacterCount", new[] { "Test2" }, "Id2"),
                RpcRequest.WithParameterList("CharacterCount", new[] { "Test23" }, "Id3")
            };
            List <RpcResponse> bulkResponse = await client.SendBulkRequestAsync(requests, "Strings");

            IntegerFromSpace responseValue = response.GetResult <IntegerFromSpace>();

            if (responseValue == null)
            {
                Console.WriteLine("null");
            }
            else
            {
                Console.WriteLine(responseValue.Test);
            }

            var additionalHeaders = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Accept-Encoding", "gzip")
            };
            var compressedClient   = new RpcClient(new Uri("http://localhost:62390/RpcApi/"), authHeaderValue, headers: additionalHeaders);
            var compressedRequest  = RpcRequest.WithParameterList("CharacterCount", new[] { "Test" }, "Id1");
            var compressedResponse = await compressedClient.SendRequestAsync(request, "Strings");
        }