Beispiel #1
0
        public Task <SubscribeResponse> Outgoing(CommandSubscribe command, Task <BaseCommand> response, IChannel channel)
        {
            var consumerId = _consumerChannels.Add(channel);

            command.ConsumerId = consumerId;
            return(response.ContinueWith(result =>
            {
                if (result.Result.CommandType == BaseCommand.Type.Error)
                {
                    _consumerChannels.Remove(consumerId);
                    result.Result.Error.Throw();
                }
                channel.Connected();
                return new SubscribeResponse(consumerId);
            }, TaskContinuationOptions.OnlyOnRanToCompletion));
        }
Beispiel #2
0
        public Task <ProducerResponse> Outgoing(CommandProducer command, Task <BaseCommand> response, IChannel channel)
        {
            var producerId = _producerChannels.Add(channel);

            command.ProducerId = producerId;
            return(response.ContinueWith(result =>
            {
                if (result.Result.CommandType == BaseCommand.Type.Error)
                {
                    _producerChannels.Remove(producerId);
                    result.Result.Error.Throw();
                }
                channel.Connected();
                return new ProducerResponse(producerId, result.Result.ProducerSuccess.ProducerName);
            }, TaskContinuationOptions.OnlyOnRanToCompletion));
        }