feat(core): update DTOs, Trade Republic client, Yahoo scrapers, and dynamic settings
This commit is contained in:
@@ -242,37 +242,42 @@ public abstract class ManagedMqttClient : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleIncomingMessageAsync(MqttApplicationMessageReceivedEventArgs e)
|
||||
private Task HandleIncomingMessageAsync(MqttApplicationMessageReceivedEventArgs e)
|
||||
{
|
||||
try
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
var topic = e.ApplicationMessage.Topic;
|
||||
var payload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
|
||||
_logger.LogInformation("MQTT message received on topic '{Topic}', length={Length}", topic, payload?.Length ?? 0);
|
||||
|
||||
// Intercept message if it belongs to the RPC response convention
|
||||
if (topic.StartsWith("services/response/"))
|
||||
try
|
||||
{
|
||||
var lastSlashIndex = topic.LastIndexOf('/');
|
||||
if (lastSlashIndex != -1)
|
||||
{
|
||||
string correlationId = topic[(lastSlashIndex + 1)..];
|
||||
var topic = e.ApplicationMessage.Topic;
|
||||
var payload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
|
||||
_logger.LogInformation("MQTT message received on topic '{Topic}', length={Length}", topic, payload?.Length ?? 0);
|
||||
|
||||
if (_pendingRequests.TryRemove(correlationId, out var tcs))
|
||||
// Intercept message if it belongs to the RPC response convention
|
||||
if (topic.StartsWith("services/response/"))
|
||||
{
|
||||
var lastSlashIndex = topic.LastIndexOf('/');
|
||||
if (lastSlashIndex != -1)
|
||||
{
|
||||
tcs.SetResult(payload);
|
||||
return; // Sinks the message, avoiding triggering OnMessageReceivedAsync for active RPC handles
|
||||
string correlationId = topic[(lastSlashIndex + 1)..];
|
||||
|
||||
if (_pendingRequests.TryRemove(correlationId, out var tcs))
|
||||
{
|
||||
tcs.SetResult(payload ?? string.Empty);
|
||||
return; // Sinks the message, avoiding triggering OnMessageReceivedAsync for active RPC handles
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Regular Pub/Sub message propagation
|
||||
await OnMessageReceivedAsync(topic, payload);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnError(ex);
|
||||
}
|
||||
// Regular Pub/Sub message propagation
|
||||
await OnMessageReceivedAsync(topic, payload ?? string.Empty);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnError(ex);
|
||||
}
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task HandleDisconnectAsync(MqttClientDisconnectedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user