add NotificationService, cleanup

This commit is contained in:
Stanley Dimant
2023-01-31 14:43:22 +01:00
parent 12f0789e9c
commit 576d005b32
17 changed files with 243 additions and 84 deletions

View File

@@ -1,7 +1,9 @@
using MareSynchronos.API.Data.Enum;
using Dalamud.Interface.Internal.Notifications;
using MareSynchronos.API.Data.Enum;
using MareSynchronos.API.Dto;
using MareSynchronos.API.Dto.Group;
using MareSynchronos.API.Dto.User;
using MareSynchronos.Mediator;
using MareSynchronos.Utils;
using Microsoft.AspNetCore.SignalR.Client;
@@ -253,19 +255,13 @@ public partial class ApiController
switch (severity)
{
case MessageSeverity.Error:
Logger.Error(message);
_dalamudUtil.PrintErrorChat(message);
_mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Error, 7500));
break;
case MessageSeverity.Warning:
Logger.Warn(message);
_dalamudUtil.PrintWarnChat(message);
_mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Warning, 7500));
break;
case MessageSeverity.Information:
Logger.Info(message);
if (!_configService.Current.HideInfoMessages)
{
_dalamudUtil.PrintInfoChat(message);
}
_mediator.Publish(new NotificationMessage("Info from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Info, 5000));
break;
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using Dalamud.Interface.Internal.Notifications;
using System.Collections.Concurrent;
using MareSynchronos.API.Routes;
using MareSynchronos.FileCache;
using MareSynchronos.Utils;
@@ -352,6 +353,7 @@ public partial class ApiController : IDisposable, IMareHubClient
_connectionDto = null;
_healthCheckTokenSource?.Cancel();
ServerState = ServerState.Reconnecting;
_mediator.Publish(new NotificationMessage("Connection lost", "Connection lost to " + _serverManager.CurrentServer!.ServerName, NotificationType.Error, 5000));
Logger.Warn("Connection closed... Reconnecting");
Logger.Warn(arg?.Message ?? string.Empty);
Logger.Warn(arg?.StackTrace ?? string.Empty);