fix introduced issue with map/map_rotate commands
This commit is contained in:
parent
570a228c92
commit
5d9c8f5369
@ -5,7 +5,7 @@
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||
<Version>2.3.2.0</Version>
|
||||
<Version>2020.0.0.0</Version>
|
||||
<Authors>RaidMax</Authors>
|
||||
<Company>Forever None</Company>
|
||||
<Product>IW4MAdmin</Product>
|
||||
@ -21,8 +21,6 @@
|
||||
<Win32Resource />
|
||||
<RootNamespace>IW4MAdmin.Application</RootNamespace>
|
||||
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
|
||||
<AssemblyVersion>2020.0.0.0</AssemblyVersion>
|
||||
<FileVersion>2020.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -952,7 +952,7 @@ namespace IW4MAdmin
|
||||
RconParser = RconParser ?? Manager.AdditionalRConParsers[0];
|
||||
EventParser = EventParser ?? Manager.AdditionalEventParsers[0];
|
||||
|
||||
RemoteConnection.SetConfiguration(RconParser.Configuration);
|
||||
RemoteConnection.SetConfiguration(RconParser);
|
||||
|
||||
var version = await this.GetMappedDvarValueOrDefaultAsync<string>("version");
|
||||
Version = version.Value;
|
||||
|
@ -26,6 +26,7 @@ namespace IW4MAdmin.Application.RCon
|
||||
public IPEndPoint Endpoint { get; private set; }
|
||||
public string RConPassword { get; private set; }
|
||||
|
||||
private IRConParser parser;
|
||||
private IRConParserConfiguration config;
|
||||
private readonly ILogger _log;
|
||||
private readonly Encoding _gameEncoding;
|
||||
@ -38,9 +39,10 @@ namespace IW4MAdmin.Application.RCon
|
||||
_log = log;
|
||||
}
|
||||
|
||||
public void SetConfiguration(IRConParserConfiguration config)
|
||||
public void SetConfiguration(IRConParser parser)
|
||||
{
|
||||
this.config = config;
|
||||
this.parser = parser;
|
||||
config = parser.Configuration;
|
||||
}
|
||||
|
||||
public async Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string parameters = "")
|
||||
@ -146,7 +148,8 @@ namespace IW4MAdmin.Application.RCon
|
||||
|
||||
try
|
||||
{
|
||||
response = await SendPayloadAsync(payload, waitForResponse);
|
||||
|
||||
response = await SendPayloadAsync(payload, waitForResponse, parser.OverrideTimeoutForCommand(parameters));
|
||||
|
||||
if ((response.Length == 0 || response[0].Length == 0) && waitForResponse)
|
||||
{
|
||||
@ -286,7 +289,7 @@ namespace IW4MAdmin.Application.RCon
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<byte[][]> SendPayloadAsync(byte[] payload, bool waitForResponse)
|
||||
private async Task<byte[][]> SendPayloadAsync(byte[] payload, bool waitForResponse, TimeSpan overrideTimeout)
|
||||
{
|
||||
var connectionState = ActiveQueries[this.Endpoint];
|
||||
var rconSocket = (Socket)connectionState.SendEventArgs.UserToken;
|
||||
@ -337,7 +340,12 @@ namespace IW4MAdmin.Application.RCon
|
||||
if (receiveDataPending)
|
||||
{
|
||||
_log.LogDebug("Waiting to asynchronously receive data on attempt #{connectionAttempts}", connectionState.ConnectionAttempts);
|
||||
if (!await Task.Run(() => connectionState.OnReceivedData.Wait(StaticHelpers.SocketTimeout(connectionState.ConnectionAttempts))))
|
||||
if (!await Task.Run(() => connectionState.OnReceivedData.Wait(
|
||||
new[]
|
||||
{
|
||||
StaticHelpers.SocketTimeout(connectionState.ConnectionAttempts),
|
||||
overrideTimeout
|
||||
}.Max())))
|
||||
{
|
||||
if (connectionState.ConnectionAttempts > 1) // this reduces some spam for unstable connections
|
||||
{
|
||||
|
@ -278,5 +278,16 @@ namespace IW4MAdmin.Application.RconParsers
|
||||
public T GetDefaultDvarValue<T>(string dvarName) => Configuration.DefaultDvarValues.ContainsKey(dvarName) ?
|
||||
(T)Convert.ChangeType(Configuration.DefaultDvarValues[dvarName], typeof(T)) :
|
||||
default;
|
||||
|
||||
public TimeSpan OverrideTimeoutForCommand(string command)
|
||||
{
|
||||
if (command.Contains("map_rotate", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
command.StartsWith("map ", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return TimeSpan.FromSeconds(30);
|
||||
}
|
||||
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ let commands = [{
|
||||
|
||||
// we want to print out a pong message for the number of times they requested
|
||||
for (var i = 0; i < times; i++) {
|
||||
gameEvent.Origin = undefined;
|
||||
gameEvent.Origin.Tell(`^${i}pong #${i + 1}^7`);
|
||||
|
||||
// don't want to wait if it's the last pong
|
||||
|
@ -17,9 +17,9 @@ namespace SharedLibraryCore.Interfaces
|
||||
Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string parameters = "");
|
||||
|
||||
/// <summary>
|
||||
/// sets the rcon parser configuration
|
||||
/// sets the rcon parser
|
||||
/// </summary>
|
||||
/// <param name="config">parser config</param>
|
||||
void SetConfiguration(IRConParserConfiguration config);
|
||||
/// <param name="config">parser</param>
|
||||
void SetConfiguration(IRConParser config);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using static SharedLibraryCore.Server;
|
||||
@ -82,5 +83,12 @@ namespace SharedLibraryCore.Interfaces
|
||||
/// <param name="dvarName">dvar key name</param>
|
||||
/// <returns></returns>
|
||||
T GetDefaultDvarValue<T>(string dvarName);
|
||||
|
||||
/// <summary>
|
||||
/// determines the amount of time to wait for the command to respond
|
||||
/// </summary>
|
||||
/// <param name="command">name of command being executed</param>
|
||||
/// <returns></returns>
|
||||
TimeSpan OverrideTimeoutForCommand(string command);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ using Microsoft.Extensions.Logging;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Exceptions;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
||||
namespace ApplicationTests
|
||||
{
|
||||
|
@ -81,13 +81,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\lib\canvas.js\" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RemoveSatellitesFromPublish" AfterTargets="ComputeFilesToPublish">
|
||||
<ItemGroup>
|
||||
<ResolvedFileToPublish Remove="@(ReferenceSatellitePaths)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Plugins\Web\StatsWeb\StatsWeb.csproj" />
|
||||
<ProjectReference Include="..\SharedLibraryCore\SharedLibraryCore.csproj" />
|
||||
|
Loading…
Reference in New Issue
Block a user