Enabled itemRouting

Disabled Backupservice.InitAsync()
This commit is contained in:
Chomp
2025-01-18 14:13:48 +00:00
parent c2c94f3b9f
commit f94349bb13
4 changed files with 20 additions and 20 deletions
+11 -11
View File
@@ -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<GetBodyResponseData<ItemEventRouterResponse>> HandleEvents(string url, ItemEventRouterRequest info, string sessionID)
public async Task<string> 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;
}
/// <summary>
@@ -41,7 +41,7 @@ public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil) // , ItemEve
return false;
}
public int? GetErrorCode(List<Warning> warnings)
public int GetErrorCode(List<Warning> warnings)
{
return int.Parse((warnings[0].Code is null
? BackendErrorCodes.UNKNOWN_ERROR.ToString()
@@ -22,15 +22,15 @@ public class HealthItemEventRouter : ItemEventRouterDefinition
protected override List<HandledRoute> GetHandledRoutes()
{
return new()
{
return
[
new HandledRoute("Eat", false),
new HandledRoute("Heal", false),
new HandledRoute("RestoreHealth", false)
};
];
}
public override Task<ItemEventRouterResponse>? HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
public override Task<ItemEventRouterResponse> HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
{
switch (url)
{
@@ -22,8 +22,8 @@ public class HideoutItemEventRouter : ItemEventRouterDefinition
protected override List<HandledRoute> 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<ItemEventRouterResponse> HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
+2 -2
View File
@@ -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
}
/**