refactor some game interface plugin approach

This commit is contained in:
RaidMax
2022-03-07 19:59:34 -06:00
parent acf66da4ca
commit 9f4d06c265
5 changed files with 384 additions and 279 deletions

View File

@ -257,6 +257,7 @@ namespace SharedLibraryCore
public EFClient Target;
public EventType Type;
public string TypeName => Type.ToString();
public GameEvent()
{

View File

@ -388,10 +388,10 @@ namespace SharedLibraryCore
public abstract Task<long> GetIdForServer(Server server = null);
public string[] ExecuteServerCommand(string command)
public string[] ExecuteServerCommand(string command, int timeoutMs = 1000)
{
var tokenSource = new CancellationTokenSource();
tokenSource.CancelAfter(TimeSpan.FromSeconds(0.5));
tokenSource.CancelAfter(TimeSpan.FromSeconds(timeoutMs));
try
{
@ -403,10 +403,10 @@ namespace SharedLibraryCore
}
}
public string GetServerDvar(string dvarName)
public string GetServerDvar(string dvarName, int timeoutMs = 1000)
{
var tokenSource = new CancellationTokenSource();
tokenSource.CancelAfter(TimeSpan.FromSeconds(0.5));
tokenSource.CancelAfter(TimeSpan.FromSeconds(timeoutMs));
try
{
return this.GetDvarAsync<string>(dvarName, token: tokenSource.Token).GetAwaiter().GetResult().Value;
@ -417,10 +417,10 @@ namespace SharedLibraryCore
}
}
public bool SetServerDvar(string dvarName, string dvarValue)
public bool SetServerDvar(string dvarName, string dvarValue, int timeoutMs = 1000)
{
var tokenSource = new CancellationTokenSource();
tokenSource.CancelAfter(TimeSpan.FromSeconds(0.5));
tokenSource.CancelAfter(TimeSpan.FromSeconds(timeoutMs));
try
{
this.SetDvarAsync(dvarName, dvarValue, tokenSource.Token).GetAwaiter().GetResult();