IW4M-Admin/Application/GameEventHandler.cs
RaidMax 99390f1f35 fixed issue with status response erroring when incorrect length
view angle vector parse fail is now a handled exception
change local host check to byte array to make it faster than comparing string
kick command now requires moderator level or higher
tempban now requires administrator level or higher
hopefully fixed negative SPM bug
pipelined the events and consolidated them to run through GameEventHandler
uniform console colors
2018-04-26 01:13:04 -05:00

47 lines
1.1 KiB
C#

using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
namespace IW4MAdmin.Application
{
class GameEventHandler : IEventHandler
{
private Queue<GameEvent> EventQueue;
private IManager Manager;
public GameEventHandler(IManager mgr)
{
EventQueue = new Queue<GameEvent>();
Manager = mgr;
}
public void AddEvent(GameEvent gameEvent)
{
#if DEBUG
Manager.GetLogger().WriteDebug($"Got new event of type {gameEvent.Type} for {gameEvent.Owner}");
#endif
EventQueue.Enqueue(gameEvent);
#if DEBUG
Manager.GetLogger().WriteDebug($"There are now {EventQueue.Count} events in queue");
#endif
Manager.SetHasEvent();
}
public string[] GetEventOutput()
{
throw new NotImplementedException();
}
public GameEvent GetNextEvent()
{
#if DEBUG
Manager.GetLogger().WriteDebug("Getting next event to be processed");
#endif
return EventQueue.Count > 0 ? EventQueue.Dequeue() : null;
}
}
}