connectivity fixes

This commit is contained in:
Stanley Dimant
2022-08-31 16:27:28 +02:00
parent 1401656cba
commit a7a3ae66a9
4 changed files with 18 additions and 26 deletions

View File

@@ -426,7 +426,9 @@ public class CachedPlayer
_penumbraRedrawEventTask = Task.Run(() =>
{
PlayerCharacter = player;
_dalamudUtil.WaitWhileCharacterIsDrawing(PlayerCharacter.Address);
using var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(5));
_dalamudUtil.WaitWhileCharacterIsDrawing(PlayerCharacter.Address, cts.Token);
if (RequestedPenumbraRedraw == false)
{
@@ -445,9 +447,9 @@ public class CachedPlayer
private void OnPlayerChanged()
{
Logger.Debug($"Player {PlayerName} changed, PenumbraRedraw is {RequestedPenumbraRedraw}");
_currentCharacterEquipment!.HasUnprocessedUpdate = false;
if (!RequestedPenumbraRedraw && PlayerCharacter is not null)
{
_currentCharacterEquipment!.HasUnprocessedUpdate = false;
Logger.Debug($"Saving new Glamourer data");
_lastGlamourerData = _ipcManager.GlamourerGetCharacterCustomization(PlayerCharacter!);
}

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>0.3.8</Version>
<Version>0.3.9</Version>
<Description></Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -60,17 +60,11 @@ namespace MareSynchronos.Models
HasUnprocessedUpdate = true;
}
}
else
else if (Address != IntPtr.Zero || DrawObjectAddress != IntPtr.Zero)
{
if (Address != IntPtr.Zero || DrawObjectAddress != IntPtr.Zero)
{
Address = IntPtr.Zero;
DrawObjectAddress = IntPtr.Zero;
HasUnprocessedUpdate = true;
}
Address = IntPtr.Zero;
DrawObjectAddress = IntPtr.Zero;
Logger.Verbose(ObjectKind + " Changed: " + _name + ", now: " + Address + ", " + DrawObjectAddress);
}
}

View File

@@ -137,16 +137,19 @@ namespace MareSynchronos.WebAPI
public async Task CreateConnections()
{
await StopConnection(_connectionCancellationTokenSource.Token);
Logger.Debug("CreateConnections called");
if (_pluginConfiguration.FullPause)
{
Logger.Info("Not recreating Connection, paused");
ServerState = ServerState.Disconnected;
_connectionDto = null;
await StopConnection(_connectionCancellationTokenSource.Token);
return;
}
await StopConnection(_connectionCancellationTokenSource.Token);
Logger.Info("Recreating Connection");
_connectionCancellationTokenSource.Cancel();
@@ -198,7 +201,6 @@ namespace MareSynchronos.WebAPI
await InitializeData(token);
_mareHub.Closed += MareHubOnClosed;
_mareHub.Reconnected += MareHubOnReconnected;
_mareHub.Reconnecting += MareHubOnReconnecting;
}
}
@@ -314,24 +316,15 @@ namespace MareSynchronos.WebAPI
return Task.CompletedTask;
}
private async Task MareHubOnReconnected(string? arg)
{
Logger.Info("Connection restored");
await Task.Delay(TimeSpan.FromSeconds(new Random().Next(5, 10)));
_ = Task.Run(CreateConnections);
}
private Task MareHubOnReconnecting(Exception? arg)
{
CurrentUploads.Clear();
CurrentDownloads.Clear();
_uploadCancellationTokenSource?.Cancel();
ServerState = ServerState.Disconnected;
Logger.Warn("Connection closed... Reconnecting");
Logger.Warn(arg?.Message ?? string.Empty);
Logger.Warn(arg?.StackTrace ?? string.Empty);
Disconnected?.Invoke();
ServerState = ServerState.Offline;
_ = Task.Run(CreateConnections);
return Task.CompletedTask;
}
@@ -340,11 +333,14 @@ namespace MareSynchronos.WebAPI
if (_mareHub is not null)
{
Logger.Info("Stopping existing connection");
await _mareHub.StopAsync(token);
_mareHub.Closed -= MareHubOnClosed;
_mareHub.Reconnected -= MareHubOnReconnected;
_mareHub.Reconnecting += MareHubOnReconnecting;
await _mareHub.StopAsync(token);
await _mareHub.DisposeAsync();
CurrentUploads.Clear();
CurrentDownloads.Clear();
_uploadCancellationTokenSource?.Cancel();
Disconnected?.Invoke();
_mareHub = null;
}