mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 16:57:22 +01:00
fully switch to mediator from events
This commit is contained in:
parent
5e7beb8518
commit
41465c2d49
24 changed files with 166 additions and 239 deletions
|
|
@ -9,6 +9,7 @@ using LZ4;
|
|||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Dto.Files;
|
||||
using MareSynchronos.API.Routes;
|
||||
using MareSynchronos.Mediator;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.Utils;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
|
@ -185,7 +186,7 @@ public partial class ApiController
|
|||
|
||||
public async Task DownloadFiles(int currentDownloadId, List<FileReplacementData> fileReplacementDto, CancellationToken ct)
|
||||
{
|
||||
DownloadStarted?.Invoke();
|
||||
_mediator.Publish(new HaltScanMessage("Download"));
|
||||
try
|
||||
{
|
||||
await DownloadFilesInternal(currentDownloadId, fileReplacementDto, ct).ConfigureAwait(false);
|
||||
|
|
@ -196,7 +197,7 @@ public partial class ApiController
|
|||
}
|
||||
finally
|
||||
{
|
||||
DownloadFinished?.Invoke();
|
||||
_mediator.Publish(new ResumeScanMessage("Download"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using MareSynchronos.API.SignalR;
|
|||
using MareSynchronos.Managers;
|
||||
using Dalamud.Utility;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Delegates;
|
||||
using MareSynchronos.Mediator;
|
||||
|
||||
namespace MareSynchronos.WebAPI;
|
||||
|
|
@ -80,11 +79,6 @@ public partial class ApiController : IDisposable, IMareHubClient
|
|||
Task.Run(() => CreateConnections(forceGetToken: true));
|
||||
}
|
||||
|
||||
public event VoidDelegate? Connected;
|
||||
public event VoidDelegate? Disconnected;
|
||||
public event VoidDelegate? DownloadStarted;
|
||||
public event VoidDelegate? DownloadFinished;
|
||||
|
||||
public ConcurrentDictionary<int, List<DownloadFileTransfer>> CurrentDownloads { get; } = new();
|
||||
|
||||
public List<FileTransfer> CurrentUploads { get; } = new();
|
||||
|
|
@ -309,7 +303,7 @@ public partial class ApiController : IDisposable, IMareHubClient
|
|||
_ = ClientHealthCheck(_healthCheckTokenSource.Token);
|
||||
|
||||
_initialized = true;
|
||||
Connected?.Invoke();
|
||||
_mediator.Publish(new ConnectedMessage());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
@ -346,7 +340,7 @@ public partial class ApiController : IDisposable, IMareHubClient
|
|||
CurrentDownloads.Clear();
|
||||
_uploadCancellationTokenSource?.Cancel();
|
||||
_healthCheckTokenSource?.Cancel();
|
||||
Disconnected?.Invoke();
|
||||
_mediator.Publish(new DisconnectedMessage());
|
||||
_pairManager.ClearPairs();
|
||||
ServerState = ServerState.Offline;
|
||||
Logger.Info("Connection closed");
|
||||
|
|
@ -361,7 +355,7 @@ public partial class ApiController : IDisposable, IMareHubClient
|
|||
Logger.Warn("Connection closed... Reconnecting");
|
||||
Logger.Warn(arg?.Message ?? string.Empty);
|
||||
Logger.Warn(arg?.StackTrace ?? string.Empty);
|
||||
Disconnected?.Invoke();
|
||||
_mediator.Publish(new DisconnectedMessage());
|
||||
_pairManager.ClearPairs();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
@ -391,7 +385,7 @@ public partial class ApiController : IDisposable, IMareHubClient
|
|||
await _mareHub.DisposeAsync().ConfigureAwait(false);
|
||||
CurrentUploads.Clear();
|
||||
CurrentDownloads.Clear();
|
||||
Disconnected?.Invoke();
|
||||
_mediator.Publish(new DisconnectedMessage());
|
||||
_pairManager.ClearPairs();
|
||||
_mareHub = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue