From f94349bb130d97fb911e56c3e533872ec1e2e78f Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 18 Jan 2025 14:13:48 +0000 Subject: [PATCH] Enabled itemRouting Disabled Backupservice.InitAsync() --- Core/Callbacks/ItemEventCallbacks.cs | 22 +++++++++---------- .../ItemEvents/HealthItemEventRouter.cs | 8 +++---- .../ItemEvents/HideoutItemEventRouter.cs | 6 ++--- Core/Services/BackupService.cs | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Core/Callbacks/ItemEventCallbacks.cs b/Core/Callbacks/ItemEventCallbacks.cs index c5e43698..54e2c54f 100644 --- a/Core/Callbacks/ItemEventCallbacks.cs +++ b/Core/Callbacks/ItemEventCallbacks.cs @@ -1,22 +1,22 @@ -using Core.Annotations; -using Core.Models.Eft.HttpResponse; +using Core.Annotations; using Core.Models.Eft.ItemEvent; using Core.Models.Enums; +using Core.Routers; using Core.Utils; namespace Core.Callbacks; [Injectable] -public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil) // , ItemEventRouter _itemEventRouter TODO: Implement ItemEventRouter +public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil, ItemEventRouter _itemEventRouter) { - public Task> HandleEvents(string url, ItemEventRouterRequest info, string sessionID) + public async Task HandleEvents(string url, ItemEventRouterRequest info, string sessionID) { - // var eventResponse = await _itemEventRouter.HandleEvents(info, sessionID); - // var result = IsCriticalError(ItemEventRouterResponse.Warnings) - // ? _httpResponseUtil.GetBody(eventResponse, GetErrorCode(eventResponse.Warnings), eventResponse.Warnings[0].Errmsg) - // : _httpResponseUtil.GetBody(eventResponse); - // TODO: Implement ItemEventRouter - throw new NotImplementedException(); + var eventResponse = await _itemEventRouter.HandleEvents(info, sessionID); + var result = IsCriticalError(eventResponse.Warnings) + ? _httpResponseUtil.GetBody(eventResponse, GetErrorCode(eventResponse.Warnings), eventResponse.Warnings[0].ErrorMessage) + : _httpResponseUtil.GetBody(eventResponse); + + return result; } /// @@ -41,7 +41,7 @@ public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil) // , ItemEve return false; } - public int? GetErrorCode(List warnings) + public int GetErrorCode(List warnings) { return int.Parse((warnings[0].Code is null ? BackendErrorCodes.UNKNOWN_ERROR.ToString() diff --git a/Core/Routers/ItemEvents/HealthItemEventRouter.cs b/Core/Routers/ItemEvents/HealthItemEventRouter.cs index 65e0b66d..719f501b 100644 --- a/Core/Routers/ItemEvents/HealthItemEventRouter.cs +++ b/Core/Routers/ItemEvents/HealthItemEventRouter.cs @@ -22,15 +22,15 @@ public class HealthItemEventRouter : ItemEventRouterDefinition protected override List GetHandledRoutes() { - return new() - { + return + [ new HandledRoute("Eat", false), new HandledRoute("Heal", false), new HandledRoute("RestoreHealth", false) - }; + ]; } - public override Task? HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output) + public override Task HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output) { switch (url) { diff --git a/Core/Routers/ItemEvents/HideoutItemEventRouter.cs b/Core/Routers/ItemEvents/HideoutItemEventRouter.cs index 32ddfc77..83c8eeca 100644 --- a/Core/Routers/ItemEvents/HideoutItemEventRouter.cs +++ b/Core/Routers/ItemEvents/HideoutItemEventRouter.cs @@ -22,8 +22,8 @@ public class HideoutItemEventRouter : ItemEventRouterDefinition protected override List GetHandledRoutes() { - return new() - { + return + [ new HandledRoute(HideoutEventActions.HIDEOUT_UPGRADE, false), new HandledRoute(HideoutEventActions.HIDEOUT_UPGRADE_COMPLETE, false), new HandledRoute(HideoutEventActions.HIDEOUT_PUT_ITEMS_IN_AREA_SLOTS, false), @@ -40,7 +40,7 @@ public class HideoutItemEventRouter : ItemEventRouterDefinition new HandledRoute(HideoutEventActions.HIDEOUT_DELETE_PRODUCTION_COMMAND, false), new HandledRoute(HideoutEventActions.HIDEOUT_CUSTOMIZATION_APPLY_COMMAND, false), new HandledRoute(HideoutEventActions.HIDEOUT_CUSTOMIZATION_SET_MANNEQUIN_POSE, false) - }; + ]; } public override Task HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output) diff --git a/Core/Services/BackupService.cs b/Core/Services/BackupService.cs index e2cbb2fa..379db090 100644 --- a/Core/Services/BackupService.cs +++ b/Core/Services/BackupService.cs @@ -1,4 +1,4 @@ -using Core.Annotations; +using Core.Annotations; namespace Core.Services; @@ -15,7 +15,7 @@ public class BackupService */ public async Task InitAsync() { - throw new NotImplementedException(); + // TODO implement } /**