7 Commits

Author SHA1 Message Date
f0cef81b5e Merge pull request #17 from ProfessorFartsalot/main
Some checks are pending
.NET Build and Publish to Gitea / build (push) Waiting to run
Fix health check, reconnect automatically on error
2025-09-05 06:12:43 +01:00
d8160effd0 Fix up client reconnect code
Simplified the reconnect code so that redis is made aware that we have a new connection.

Made the reconnect fire immediately on error rather than waiting for subsequent errors.
2025-09-04 21:50:47 -04:00
18da07763c Add in extra check to see if hub server DC'd 2025-09-04 18:41:44 -04:00
3c448f2290 Fix health check, reconnect automatically on error
+ Made health check actually do something instead of just logging connection health issues.

+ Requires server code change to enable the health check so it's not just returning false all the time.

+ Forcibly reconnects the client when they've had connection issues.
2025-09-04 17:18:26 -04:00
cadc7e223f minor fixes 2025-09-04 14:26:15 +01:00
e1baca7940 Version bump
Some checks failed
.NET Build and Publish to Gitea / build (push) Has been cancelled
2025-09-03 16:11:51 +01:00
c2e0cf65a8 Packages update 2025-09-03 16:07:00 +01:00
3 changed files with 48 additions and 10 deletions

View File

@@ -2,8 +2,8 @@
<Project Sdk="Dalamud.NET.Sdk/13.0.0"> <Project Sdk="Dalamud.NET.Sdk/13.0.0">
<PropertyGroup> <PropertyGroup>
<AssemblyName>Snowcloak</AssemblyName> <AssemblyName>Snowcloak</AssemblyName>
<Version>0.2.1</Version> <Version>0.2.2</Version>
<PackageProjectUrl>https://github.com/Eauldane/SnowcloakClient/</PackageProjectUrl> <PackageProjectUrl>https://git.snowcloak-sync.com/Eauldane/SnowcloakClient/</PackageProjectUrl>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -129,7 +129,7 @@ public class DrawGroupPair : DrawPairBase
protected override float DrawRightSide(float textPosY, float originalY) protected override float DrawRightSide(float textPosY, float originalY)
{ {
var pauseIcon = _fullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; var pauseIcon = _pair.IsPaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = _uiSharedService.GetIconButtonSize(pauseIcon); var pauseIconSize = _uiSharedService.GetIconButtonSize(pauseIcon);
var spacingX = ImGui.GetStyle().ItemSpacing.X; var spacingX = ImGui.GetStyle().ItemSpacing.X;
var entryUID = _fullInfoDto.UserAliasOrUID; var entryUID = _fullInfoDto.UserAliasOrUID;
@@ -296,9 +296,10 @@ public class DrawGroupPair : DrawPairBase
if (_uiSharedService.IconButton(pauseIcon)) if (_uiSharedService.IconButton(pauseIcon))
{ {
var perm = _fullInfoDto.GroupUserPermissions; var perm = _pair.UserPair!.OwnPermissions;
var newPaused = !perm.IsPaused(); perm.SetPaused(!perm.IsPaused());
perm.SetPaused(newPaused); _ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm));
} }
UiSharedService.AttachToolTip(!_fullInfoDto.GroupUserPermissions.IsPaused() UiSharedService.AttachToolTip(!_fullInfoDto.GroupUserPermissions.IsPaused()

View File

@@ -183,6 +183,8 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
_connectionDto = await GetConnectionDto().ConfigureAwait(false); _connectionDto = await GetConnectionDto().ConfigureAwait(false);
await CheckClientHealth().ConfigureAwait(false);
ServerState = ServerState.Connected; ServerState = ServerState.Connected;
var currentClientVer = Assembly.GetExecutingAssembly().GetName().Version!; var currentClientVer = Assembly.GetExecutingAssembly().GetName().Version!;
@@ -308,14 +310,24 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
_ = Task.Run(async () => await StopConnection(ServerState.Disconnected).ConfigureAwait(false)); _ = Task.Run(async () => await StopConnection(ServerState.Disconnected).ConfigureAwait(false));
_connectionCancellationTokenSource?.Cancel(); _connectionCancellationTokenSource?.Cancel();
} }
private int _unhealthy = 0;
private async Task ClientHealthCheck(CancellationToken ct) private async Task ClientHealthCheck(CancellationToken ct)
{ {
while (!ct.IsCancellationRequested && _mareHub != null) while (!ct.IsCancellationRequested && _mareHub != null)
{ {
await Task.Delay(TimeSpan.FromSeconds(30), ct).ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(30), ct).ConfigureAwait(false);
Logger.LogDebug("Checking Client Health State"); var healthy = await CheckClientHealth().ConfigureAwait(false);
_ = await CheckClientHealth().ConfigureAwait(false); if (!healthy || _mareHub.State != HubConnectionState.Connected)
{
_unhealthy++;
if (_unhealthy > 0)
{
Logger.LogWarning("Health check failed, forcing reconnect. ClientHealth: {0} HubConnected: {1}", healthy, _mareHub.State != HubConnectionState.Connected);
await ForceResetConnection().ConfigureAwait(false);
_unhealthy = 0;
}
}
else _unhealthy = 0;
} }
} }
@@ -391,7 +403,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
{ {
var users = await GroupsGetUsersInGroup(group).ConfigureAwait(false); var users = await GroupsGetUsersInGroup(group).ConfigureAwait(false);
foreach (var user in users) foreach (var user in users)
{ {
Logger.LogDebug("Group Pair: {user}", user); Logger.LogDebug("Group Pair: {user}", user);
_pairManager.AddGroupPair(user); _pairManager.AddGroupPair(user);
} }
@@ -478,5 +490,30 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
ServerState = state; ServerState = state;
} }
//Because this plugin really likes to bug out with connections, lets "fix" it....
public async Task ForceResetConnection()
{
if (!_initialized) return;
Logger.LogInformation("ForceReconnect called");
try
{
await StopConnection(ServerState.Disconnected).ConfigureAwait(false);
// Cancel any ongoing health checks to prevent conflicts
_healthCheckTokenSource?.Cancel();
_healthCheckTokenSource?.Dispose();
_healthCheckTokenSource = null;
await CreateConnections().ConfigureAwait(false);
Logger.LogInformation("ForceReconnect completed successfully");
}
catch (Exception ex)
{
Logger.LogError(ex, "Failure during ForceReconnect, disconnecting");
await StopConnection(ServerState.Disconnected).ConfigureAwait(false);
}
}
} }
#pragma warning restore MA0040 #pragma warning restore MA0040