diff --git a/Plugins/ScriptPlugins/GameInterface.js b/Plugins/ScriptPlugins/GameInterface.js index bb0d8da4e..f3e4ca3f3 100644 --- a/Plugins/ScriptPlugins/GameInterface.js +++ b/Plugins/ScriptPlugins/GameInterface.js @@ -307,6 +307,11 @@ const sendEvent = (server, responseExpected, event, subtype, origin, target, dat const start = new Date(); while (pendingOut && pendingCheckCount <= 10) { + if (server.Throttled) { + logger.WriteWarning('Server is throttled, so we are not attempting to send data'); + return; + } + try { const out = server.GetServerDvar(outDvar); pendingOut = !(out == null || out === '' || out === 'null'); @@ -318,6 +323,7 @@ const sendEvent = (server, responseExpected, event, subtype, origin, target, dat logger.WriteDebug('Waiting for event bus to be cleared'); System.Threading.Tasks.Task.Delay(1000).Wait(); } + pendingCheckCount++; } @@ -397,6 +403,10 @@ const initialize = (server) => { }; const pollForEvents = server => { + if (server.Throttled) { + return; + } + const logger = _serviceResolver.ResolveService('ILogger'); let input; diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index 48102eebf..85ef3819b 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -391,7 +391,7 @@ namespace SharedLibraryCore public string[] ExecuteServerCommand(string command) { var tokenSource = new CancellationTokenSource(); - tokenSource.CancelAfter(TimeSpan.FromSeconds(5)); + tokenSource.CancelAfter(TimeSpan.FromSeconds(0.5)); try { @@ -406,7 +406,7 @@ namespace SharedLibraryCore public string GetServerDvar(string dvarName) { var tokenSource = new CancellationTokenSource(); - tokenSource.CancelAfter(TimeSpan.FromSeconds(5)); + tokenSource.CancelAfter(TimeSpan.FromSeconds(0.5)); try { return this.GetDvarAsync(dvarName, token: tokenSource.Token).GetAwaiter().GetResult().Value; @@ -420,7 +420,7 @@ namespace SharedLibraryCore public bool SetServerDvar(string dvarName, string dvarValue) { var tokenSource = new CancellationTokenSource(); - tokenSource.CancelAfter(TimeSpan.FromSeconds(5)); + tokenSource.CancelAfter(TimeSpan.FromSeconds(0.5)); try { this.SetDvarAsync(dvarName, dvarValue, tokenSource.Token).GetAwaiter().GetResult();