This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
gameservicewarden/GameServiceWarden/GameServiceWarden.Core/UI/IPCController.cs

41 lines
1.4 KiB
C#

using System.Diagnostics;
using System.Text.Json;
using GameServiceWarden.InteractionAPI;
using GameServiceWarden.InteractionAPI.Communicable.Requests;
using GameServiceWarden.Core.Module;
using SimpleLogger;
namespace GameServiceWarden.Core.UI
{
public class IPCController
{
private IPCMediator mediator;
private IServiceManagerActionExecuter serviceExecutioner;
public IPCController(IPCMediator mediator, IServiceManagerActionExecuter serviceExecutioner)
{
this.mediator = mediator;
this.serviceExecutioner = serviceExecutioner;
}
public void Process() {
Logger.Log("Beginning to process interface requests.");
mediator.Open();
(string, CommunicableType, byte[]) action;
while (mediator.RequestQueue.TryTake(out action))
{
switch (action.Item2)
{
case CommunicableType.Delta:
ServiceRequest delta = JsonSerializer.Deserialize<ServiceRequest>(action.Item3);
serviceExecutioner.ExecuteAction(delta.serviceManagerAction);
break;
case CommunicableType.View:
serviceExecutioner.View();
break;
}
}
mediator.Close();
}
}
}