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>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||||
<Version>2.3.2.0</Version>
|
<Version>2020.0.0.0</Version>
|
||||||
<Authors>RaidMax</Authors>
|
<Authors>RaidMax</Authors>
|
||||||
<Company>Forever None</Company>
|
<Company>Forever None</Company>
|
||||||
<Product>IW4MAdmin</Product>
|
<Product>IW4MAdmin</Product>
|
||||||
@ -21,8 +21,6 @@
|
|||||||
<Win32Resource />
|
<Win32Resource />
|
||||||
<RootNamespace>IW4MAdmin.Application</RootNamespace>
|
<RootNamespace>IW4MAdmin.Application</RootNamespace>
|
||||||
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
|
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
|
||||||
<AssemblyVersion>2020.0.0.0</AssemblyVersion>
|
|
||||||
<FileVersion>2020.0.0.0</FileVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -952,7 +952,7 @@ namespace IW4MAdmin
|
|||||||
RconParser = RconParser ?? Manager.AdditionalRConParsers[0];
|
RconParser = RconParser ?? Manager.AdditionalRConParsers[0];
|
||||||
EventParser = EventParser ?? Manager.AdditionalEventParsers[0];
|
EventParser = EventParser ?? Manager.AdditionalEventParsers[0];
|
||||||
|
|
||||||
RemoteConnection.SetConfiguration(RconParser.Configuration);
|
RemoteConnection.SetConfiguration(RconParser);
|
||||||
|
|
||||||
var version = await this.GetMappedDvarValueOrDefaultAsync<string>("version");
|
var version = await this.GetMappedDvarValueOrDefaultAsync<string>("version");
|
||||||
Version = version.Value;
|
Version = version.Value;
|
||||||
|
@ -26,6 +26,7 @@ namespace IW4MAdmin.Application.RCon
|
|||||||
public IPEndPoint Endpoint { get; private set; }
|
public IPEndPoint Endpoint { get; private set; }
|
||||||
public string RConPassword { get; private set; }
|
public string RConPassword { get; private set; }
|
||||||
|
|
||||||
|
private IRConParser parser;
|
||||||
private IRConParserConfiguration config;
|
private IRConParserConfiguration config;
|
||||||
private readonly ILogger _log;
|
private readonly ILogger _log;
|
||||||
private readonly Encoding _gameEncoding;
|
private readonly Encoding _gameEncoding;
|
||||||
@ -38,9 +39,10 @@ namespace IW4MAdmin.Application.RCon
|
|||||||
_log = log;
|
_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 = "")
|
public async Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string parameters = "")
|
||||||
@ -146,7 +148,8 @@ namespace IW4MAdmin.Application.RCon
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = await SendPayloadAsync(payload, waitForResponse);
|
|
||||||
|
response = await SendPayloadAsync(payload, waitForResponse, parser.OverrideTimeoutForCommand(parameters));
|
||||||
|
|
||||||
if ((response.Length == 0 || response[0].Length == 0) && waitForResponse)
|
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 connectionState = ActiveQueries[this.Endpoint];
|
||||||
var rconSocket = (Socket)connectionState.SendEventArgs.UserToken;
|
var rconSocket = (Socket)connectionState.SendEventArgs.UserToken;
|
||||||
@ -337,7 +340,12 @@ namespace IW4MAdmin.Application.RCon
|
|||||||
if (receiveDataPending)
|
if (receiveDataPending)
|
||||||
{
|
{
|
||||||
_log.LogDebug("Waiting to asynchronously receive data on attempt #{connectionAttempts}", connectionState.ConnectionAttempts);
|
_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
|
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) ?
|
public T GetDefaultDvarValue<T>(string dvarName) => Configuration.DefaultDvarValues.ContainsKey(dvarName) ?
|
||||||
(T)Convert.ChangeType(Configuration.DefaultDvarValues[dvarName], typeof(T)) :
|
(T)Convert.ChangeType(Configuration.DefaultDvarValues[dvarName], typeof(T)) :
|
||||||
default;
|
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
|
// we want to print out a pong message for the number of times they requested
|
||||||
for (var i = 0; i < times; i++) {
|
for (var i = 0; i < times; i++) {
|
||||||
gameEvent.Origin = undefined;
|
|
||||||
gameEvent.Origin.Tell(`^${i}pong #${i + 1}^7`);
|
gameEvent.Origin.Tell(`^${i}pong #${i + 1}^7`);
|
||||||
|
|
||||||
// don't want to wait if it's the last pong
|
// 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 = "");
|
Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string parameters = "");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// sets the rcon parser configuration
|
/// sets the rcon parser
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config">parser config</param>
|
/// <param name="config">parser</param>
|
||||||
void SetConfiguration(IRConParserConfiguration config);
|
void SetConfiguration(IRConParser config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SharedLibraryCore.Database.Models;
|
using SharedLibraryCore.Database.Models;
|
||||||
using static SharedLibraryCore.Server;
|
using static SharedLibraryCore.Server;
|
||||||
@ -82,5 +83,12 @@ namespace SharedLibraryCore.Interfaces
|
|||||||
/// <param name="dvarName">dvar key name</param>
|
/// <param name="dvarName">dvar key name</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
T GetDefaultDvarValue<T>(string dvarName);
|
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;
|
||||||
using SharedLibraryCore.Exceptions;
|
using SharedLibraryCore.Exceptions;
|
||||||
using SharedLibraryCore.Configuration;
|
using SharedLibraryCore.Configuration;
|
||||||
|
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||||
|
|
||||||
namespace ApplicationTests
|
namespace ApplicationTests
|
||||||
{
|
{
|
||||||
|
@ -82,12 +82,6 @@
|
|||||||
<Folder Include="wwwroot\lib\canvas.js\" />
|
<Folder Include="wwwroot\lib\canvas.js\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="RemoveSatellitesFromPublish" AfterTargets="ComputeFilesToPublish">
|
|
||||||
<ItemGroup>
|
|
||||||
<ResolvedFileToPublish Remove="@(ReferenceSatellitePaths)" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Plugins\Web\StatsWeb\StatsWeb.csproj" />
|
<ProjectReference Include="..\Plugins\Web\StatsWeb\StatsWeb.csproj" />
|
||||||
<ProjectReference Include="..\SharedLibraryCore\SharedLibraryCore.csproj" />
|
<ProjectReference Include="..\SharedLibraryCore\SharedLibraryCore.csproj" />
|
||||||
|
Loading…
Reference in New Issue
Block a user