Esempio n. 1
0
 private async Task ProcessResponse(GatewayResponse response)
 {
     try
     {
         using (var serviceScope = Services.CreateScope())
         {
             {
                 var commandQueues = serviceScope.ServiceProvider.GetRequiredService <CommandQueues>();
                 commandQueues.TryPostResponse(gatewayId, response);
             }
             if (!response.HasError())
             {
                 var responseProcessor = serviceScope.ServiceProvider.GetRequiredService <GatewayResponseProcessor>();
                 await responseProcessor.ProcessResponse(response.GetMessage());
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine($"Unknown exception during message processing. {e.Message}");
     }
 }
Esempio n. 2
0
            public void TryPostResponse(GatewayResponse response)
            {
                if (response.SequenceNumber == 0)
                {
                    return;
                }

                try
                {
                    PendingRequests[response.SequenceNumber].SetResult(response.GetMessage());
                }
                catch (KeyNotFoundException)
                {
                    // no such response.SequenceNumber -> probably timeouted and already deleted
                }
                catch (GatewayResponseError e)
                {
                    PendingRequests[response.SequenceNumber].SetException(e);
                }
                finally
                {
                    PendingRequests.TryRemove(response.SequenceNumber, out _);
                }
            }