Example #1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var message = HttpMessageSerializer.Serialize(request);

            var response = await Client.GetResponseAsync(new IpcRequestMessage(request.RequestUri?.ToString() ?? request.Method.ToString(),
                                                                               message));

            return(HttpMessageSerializer.DeserializeToResponse(response.Buffer));
        }
Example #2
0
        public IpcCore(IServiceProvider serviceProvider)
        {
            IpcServer = new IpcProvider(IpcServerName, new IpcConfiguration()
            {
                DefaultIpcRequestHandler = new DelegateIpcRequestHandler(async context =>
                {
                    var server = (TestServer)serviceProvider.GetRequiredService <IServer>();

                    var requestMessage = HttpMessageSerializer.DeserializeToRequest(context.IpcBufferMessage.Buffer);

                    var clientHandler = (ClientHandler)server.CreateHandler();
                    var response      = await clientHandler.SendInnerAsync(requestMessage, CancellationToken.None);

                    var responseByteList = HttpMessageSerializer.Serialize(response);

                    return(new IpcHandleRequestMessageResult(new IpcRequestMessage($"[Response][{requestMessage.Method}] {requestMessage.RequestUri}", responseByteList)));
                })
            });
        }