public Task <object> RelayRequestAsync(string correlationId, object request, string clientId, ClientIdTypeEnum clientIdType) { var lookup = GetLookup(clientIdType, clientId); if (lookup != null) { var client = Clients.Client(lookup.ConnectionId); if (client != null) { var tcs = new TaskCompletionSource <object>(); if (RequestResponseCache.TryAdd(correlationId, tcs)) { // todo: refactor the client invocation method signatures client.SendAsync(CX.WorkerMethodName, request); return(tcs.Task); } } } // fallthrough var canceled = new TaskCompletionSource <object>(); canceled.SetResult(request); return(canceled.Task); }
public TResponseMsg RequestResponse(TRequestMsg request, string clientId, ClientIdTypeEnum clientIdType) { return(_appServiceClient.RelayRequestResponse <TRequestMsg, TResponseMsg>(request, clientId, clientIdType)); }
public TResponse RelayRequestResponse <TRequest, TResponse>(TRequest request, string clientId, ClientIdTypeEnum clientIdType) where TRequest : RelayMessageBase where TResponse : RelayMessageBase { var result = this.Proxy.InvokeAsync <object>(CX.RelayRequestMethodName, request.CorrelationId, request, clientId, clientIdType).Result; var json = result as JObject; var response = json.ToObject <TResponse>(); return(response); }