Exemplo n.º 1
0
        public Task UnsubscribeAsync(MessageContext <TranslationUnsubscriptionRequest> messageContext, CancellationToken cancellationToken)
        {
            Task marketTask, dataTask;

            if (subscriptions.TryRemove(messageContext.Message.Id, out var subscription))
            {
                if (subscription.Booking.BookedMarket)
                {
                    marketTask = feedManager.SendMarketUnsubscribeRequestAsync(messageContext, cancellationToken);
                }
                else
                {
                    marketTask = Task.CompletedTask;
                }

                if (subscription.Booking.BookedData)
                {
                    dataTask = feedManager.SendDataUnsubscribeRequestAsync(messageContext, cancellationToken);
                }
                else
                {
                    dataTask = Task.CompletedTask;
                }

                return(Task.WhenAll(dataTask, marketTask));
            }

            return(Task.CompletedTask);
        }