mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
implement more robust command api and login
improve web console command response reliability and consistency
This commit is contained in:
@ -52,8 +52,10 @@ namespace WebfrontCore.Controllers
|
||||
var remoteEvent = new GameEvent()
|
||||
{
|
||||
Type = GameEvent.EventType.Command,
|
||||
Data = command.StartsWith(_appconfig.CommandPrefix) || command.StartsWith(_appconfig.BroadcastCommandPrefix) ?
|
||||
command : $"{_appconfig.CommandPrefix}{command}",
|
||||
Data = command.StartsWith(_appconfig.CommandPrefix) ||
|
||||
command.StartsWith(_appconfig.BroadcastCommandPrefix)
|
||||
? command
|
||||
: $"{_appconfig.CommandPrefix}{command}",
|
||||
Origin = client,
|
||||
Owner = server,
|
||||
IsRemote = true
|
||||
@ -65,7 +67,8 @@ namespace WebfrontCore.Controllers
|
||||
try
|
||||
{
|
||||
// wait for the event to process
|
||||
var completedEvent = await remoteEvent.WaitAsync(Utilities.DefaultCommandTimeout, server.Manager.CancellationToken);
|
||||
var completedEvent =
|
||||
await remoteEvent.WaitAsync(Utilities.DefaultCommandTimeout, server.Manager.CancellationToken);
|
||||
|
||||
if (completedEvent.FailReason == GameEvent.EventFailReason.Timeout)
|
||||
{
|
||||
@ -81,13 +84,11 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
else
|
||||
{
|
||||
response = response = server.CommandResult.Where(c => c.ClientId == client.ClientId).ToArray();
|
||||
}
|
||||
|
||||
// remove the added command response
|
||||
for (int i = 0; i < response?.Length; i++)
|
||||
{
|
||||
server.CommandResult.Remove(response[i]);
|
||||
response = completedEvent.Output.Select(output => new CommandResponseInfo()
|
||||
{
|
||||
Response = output,
|
||||
ClientId = client.ClientId
|
||||
}).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,4 +107,4 @@ namespace WebfrontCore.Controllers
|
||||
return View("_Response", response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user