public async Task <SubscribeResponse> Send(CommandSubscribe command, IChannel channel, CancellationToken cancellationToken) { ThrowIfDisposed(); Task <SubscribeResponse>?responseTask; using (await _lock.Lock(cancellationToken).ConfigureAwait(false)) { responseTask = _channelManager.Outgoing(command, channel); var sequence = Serializer.Serialize(command.AsBaseCommand()); await _stream.Send(sequence).ConfigureAwait(false); } return(await responseTask.ConfigureAwait(false)); }
public async Task <SubscribeResponse> Send(CommandSubscribe command, IChannel channel) { Task <SubscribeResponse>?responseTask = null; using (await _lock.Lock()) { var baseCommand = command.AsBaseCommand(); var requestResponseTask = _requestResponseHandler.Outgoing(baseCommand); responseTask = _channelManager.Outgoing(command, requestResponseTask, channel); var sequence = Serializer.Serialize(baseCommand); await _stream.Send(sequence); } return(await responseTask); }
public async Task <SubscribeResponse> Send(CommandSubscribe command, IConsumerProxy proxy) { Task <BaseCommand>?responseTask = null; using (await _lock.Lock()) { _consumerManager.Outgoing(command, proxy); var baseCommand = command.AsBaseCommand(); responseTask = _requestResponseHandler.Outgoing(baseCommand); var sequence = Serializer.Serialize(baseCommand); await _stream.Send(sequence); } var response = await responseTask; if (response.CommandType == BaseCommand.Type.Error) { _consumerManager.Remove(command.ConsumerId); response.Error.Throw(); } return(new SubscribeResponse(command.ConsumerId)); }