fix latent issue with password login due to not retreiving password/salt
set semaphore count properly for event execution throttling
This commit is contained in:
parent
c82139b88c
commit
b49592d666
@ -13,7 +13,6 @@ namespace IW4MAdmin.Application
|
|||||||
{
|
{
|
||||||
private const int MAX_CONCURRENT_EVENTS = 10;
|
private const int MAX_CONCURRENT_EVENTS = 10;
|
||||||
private readonly ApplicationManager _manager;
|
private readonly ApplicationManager _manager;
|
||||||
private readonly EventProfiler _profiler;
|
|
||||||
private readonly SemaphoreSlim _processingEvents;
|
private readonly SemaphoreSlim _processingEvents;
|
||||||
private static readonly GameEvent.EventType[] overrideEvents = new[]
|
private static readonly GameEvent.EventType[] overrideEvents = new[]
|
||||||
{
|
{
|
||||||
@ -26,41 +25,33 @@ namespace IW4MAdmin.Application
|
|||||||
public GameEventHandler(IManager mgr)
|
public GameEventHandler(IManager mgr)
|
||||||
{
|
{
|
||||||
_manager = (ApplicationManager)mgr;
|
_manager = (ApplicationManager)mgr;
|
||||||
_profiler = new EventProfiler(mgr.GetLogger(0));
|
_processingEvents = new SemaphoreSlim(MAX_CONCURRENT_EVENTS, MAX_CONCURRENT_EVENTS);
|
||||||
_processingEvents = new SemaphoreSlim(0, MAX_CONCURRENT_EVENTS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task GameEventHandler_GameEventAdded(object sender, GameEventArgs args)
|
private Task GameEventHandler_GameEventAdded(object sender, GameEventArgs args)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
try
|
||||||
var start = DateTime.Now;
|
|
||||||
#endif
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
try
|
// this is not elegant and there's probably a much better way to do it, but it works for now
|
||||||
{
|
_processingEvents.Wait();
|
||||||
// this is not elegant and there's probably a much better way to do it, but it works for now
|
EventApi.OnGameEvent(sender, args);
|
||||||
await _processingEvents.WaitAsync();
|
return _manager.ExecuteEvent(args.Event);
|
||||||
EventApi.OnGameEvent(sender, args);
|
}
|
||||||
await _manager.ExecuteEvent(args.Event);
|
|
||||||
#if DEBUG
|
|
||||||
_profiler.Profile(start, DateTime.Now, args.Event);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
{
|
||||||
|
if (_processingEvents.CurrentCount < MAX_CONCURRENT_EVENTS)
|
||||||
{
|
{
|
||||||
if (_processingEvents.CurrentCount < MAX_CONCURRENT_EVENTS)
|
_processingEvents.Release();
|
||||||
{
|
|
||||||
_processingEvents.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddEvent(GameEvent gameEvent)
|
public void AddEvent(GameEvent gameEvent)
|
||||||
|
@ -384,7 +384,9 @@ namespace SharedLibraryCore.Services
|
|||||||
Masked = _client.Masked,
|
Masked = _client.Masked,
|
||||||
NetworkId = _client.NetworkId,
|
NetworkId = _client.NetworkId,
|
||||||
TotalConnectionTime = _client.TotalConnectionTime,
|
TotalConnectionTime = _client.TotalConnectionTime,
|
||||||
AliasLink = _client.AliasLink
|
AliasLink = _client.AliasLink,
|
||||||
|
Password = _client.Password,
|
||||||
|
PasswordSalt = _client.PasswordSalt
|
||||||
})
|
})
|
||||||
.FirstOrDefault(c => c.NetworkId == networkId)
|
.FirstOrDefault(c => c.NetworkId == networkId)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user