Create ensure connection with webscoket

This commit is contained in:
atef 2026-02-27 12:55:02 +01:00
parent 545bb96b9d
commit 1657cb2b61
1 changed files with 24 additions and 0 deletions

View File

@ -44,6 +44,30 @@ public static class RabbitMqManager
return true;
}
public static Boolean EnsureConnected(StatusMessage currentSalimaxState, string? s3Bucket, string vpnServerIp)
{
try
{
if (_connection == null || !_connection.IsOpen ||
_channel == null || _channel.IsClosed)
{
Console.WriteLine("⚠ RabbitMQ connection lost. Reconnecting...");
_connection?.Dispose();
_channel?.Dispose();
return SubscribeToQueue(currentSalimaxState, s3Bucket, vpnServerIp);
}
return true;
}
catch (Exception ex)
{
Console.WriteLine("❌ Error while ensuring RabbitMQ connection: " + ex);
return false;
}
}
public static void InformMiddleware(StatusMessage status)
{
var message = JsonSerializer.Serialize(status);