public Task GetPriceUpdates(IRequestContext context, IMessage message) { using (LogContext.PushProperty("InstanceId", InstanceId)) { Log.Debug("{host} Received GetPriceUpdates from [{user}] for replyTo {replyTo}", this, context.Username ?? "Unknown User", context.ReplyTo); var spotStreamRequest = JsonConvert.DeserializeObject <GetSpotStreamRequestDto>(Encoding.UTF8.GetString(message.Payload)); var replyTo = context.ReplyTo; var endpoint = _broker.GetPrivateEndPoint <SpotPriceDto>(replyTo, context.CorrelationId); var disposable = _service.GetPriceUpdates(context, spotStreamRequest) .TakeUntil(endpoint.TerminationSignal) .Finally(() => Log.Debug("Tidying up subscription from {replyTo}.", replyTo)) .Subscribe(endpoint); _cleanup.Add(disposable); return(Task.CompletedTask); } }
public async Task GetPriceUpdates(IRequestContext context, IMessage message) { Log.DebugFormat("{1} Received GetPriceUpdates from [{0}]", context.UserSession.Username ?? "Unknown User", this); var spotStreamRequest = JsonConvert.DeserializeObject <GetSpotStreamRequestDto>(Encoding.UTF8.GetString(message.Payload)); var replyTo = message.ReplyTo; var endpoint = await _broker.GetPrivateEndPoint <SpotPriceDto>(replyTo); var disposable = _service.GetPriceUpdates(context, spotStreamRequest) .TakeUntil(endpoint.TerminationSignal) .Subscribe(endpoint); _cleanup.Add(disposable); }