Example #1
0
        public async Task <TResponse> RequestAsync <TResponse>(IIpcRequest packet) where TResponse : class, IIpcResponse
        {
            // add packet to requests
            PendingRequest request = _requestFactory.Create(packet);

            if (!_pendingRequests.TryAdd(packet.Id, request))
            {
                return(null);
            }

            // create the packet container
            PacketContainer container = _packetFactory.ToPacket(packet.GetType(), packet);

            await SendAsync(container);

            IIpcResponse tmp = await request.Response.Task;

            return(tmp as TResponse);
        }
Example #2
0
 private Task <TResponse> RequestAsync <TResponse>(IIpcRequest request) where TResponse : class, IIpcResponse
 {
     return(_client.RequestAsync <TResponse>(request));
 }
 public PendingRequest Create(IIpcRequest request) => new PendingRequest
 {
     Request  = request,
     Response = new TaskCompletionSource <IIpcResponse>()
 };