add tell async and update SharedLibraryCore version
This commit is contained in:
parent
36eb45bb2e
commit
63b04be4c7
@ -709,37 +709,35 @@ namespace SharedLibraryCore.Commands
|
|||||||
RequiresTarget = false;
|
RequiresTarget = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task ExecuteAsync(GameEvent E)
|
public override async Task ExecuteAsync(GameEvent gameEvent)
|
||||||
{
|
{
|
||||||
if (E.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules?.Length < 1 &&
|
if (gameEvent.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules?.Length < 1 &&
|
||||||
E.Owner.ServerConfig.Rules?.Length < 1)
|
gameEvent.Owner.ServerConfig.Rules?.Length < 1)
|
||||||
{
|
{
|
||||||
var _ = E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)
|
var _ = gameEvent.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)
|
||||||
? E.Owner.Broadcast(_translationLookup["COMMANDS_RULES_NONE"])
|
? gameEvent.Owner.Broadcast(_translationLookup["COMMANDS_RULES_NONE"])
|
||||||
: E.Origin.Tell(_translationLookup["COMMANDS_RULES_NONE"]);
|
: gameEvent.Origin.Tell(_translationLookup["COMMANDS_RULES_NONE"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var rules = new List<string>();
|
var rules = new List<string>();
|
||||||
rules.AddRange(E.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules);
|
rules.AddRange(gameEvent.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules);
|
||||||
if (E.Owner.ServerConfig.Rules != null)
|
if (gameEvent.Owner.ServerConfig.Rules != null)
|
||||||
{
|
{
|
||||||
rules.AddRange(E.Owner.ServerConfig.Rules);
|
rules.AddRange(gameEvent.Owner.ServerConfig.Rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ruleFomat = rules.Select(r => $"- {r}");
|
var ruleFormat = rules.Select(r => $"- {r}");
|
||||||
if (E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix))
|
if (gameEvent.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix))
|
||||||
{
|
{
|
||||||
E.Owner.Broadcast(ruleFomat);
|
gameEvent.Owner.Broadcast(ruleFormat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
E.Origin.Tell(ruleFomat);
|
await gameEvent.Origin.TellAsync(ruleFormat, gameEvent.Owner.Manager.CancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +335,14 @@ namespace SharedLibraryCore
|
|||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (_eventFinishedWaiter.CurrentCount == 0)
|
||||||
|
{
|
||||||
|
_eventFinishedWaiter.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!processed)
|
if (!processed)
|
||||||
{
|
{
|
||||||
using (LogContext.PushProperty("Server", Owner?.ToString()))
|
using (LogContext.PushProperty("Server", Owner?.ToString()))
|
||||||
|
@ -177,6 +177,7 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
public void Tell(IEnumerable<string> messages)
|
public void Tell(IEnumerable<string> messages)
|
||||||
{
|
{
|
||||||
foreach (var message in messages)
|
foreach (var message in messages)
|
||||||
@ -187,6 +188,14 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task TellAsync(IEnumerable<string> messages, CancellationToken token =default)
|
||||||
|
{
|
||||||
|
foreach (var message in messages)
|
||||||
|
{
|
||||||
|
await Tell(message).WaitAsync(Utilities.DefaultCommandTimeout, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// warn a client with given reason
|
/// warn a client with given reason
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace SharedLibraryCore.RCon
|
namespace SharedLibraryCore.RCon
|
||||||
{
|
{
|
||||||
@ -48,16 +47,6 @@ namespace SharedLibraryCore.RCon
|
|||||||
COMMAND_STATUS
|
COMMAND_STATUS
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// line seperator char included in response from the server
|
|
||||||
/// </summary>
|
|
||||||
public static char SeperatorChar = (char)int.Parse("0a", NumberStyles.AllowHexSpecifier);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// interval in milliseconds to wait before sending the next RCon request
|
|
||||||
/// </summary>
|
|
||||||
public static readonly int FloodProtectionInterval = 750;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// timeout in seconds to wait for a socket send or receive before giving up
|
/// timeout in seconds to wait for a socket send or receive before giving up
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
|
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
|
||||||
<Version>2022.2.28.1</Version>
|
<Version>2022.3.23.1</Version>
|
||||||
<Authors>RaidMax</Authors>
|
<Authors>RaidMax</Authors>
|
||||||
<Company>Forever None</Company>
|
<Company>Forever None</Company>
|
||||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||||
@ -19,7 +19,9 @@
|
|||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<Description>Shared Library for IW4MAdmin</Description>
|
<Description>Shared Library for IW4MAdmin</Description>
|
||||||
<PackageVersion>2022.2.28.1</PackageVersion>
|
<PackageVersion>2022.3.23.1</PackageVersion>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
|
||||||
@ -27,6 +29,10 @@
|
|||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentValidation" Version="10.3.6" />
|
<PackageReference Include="FluentValidation" Version="10.3.6" />
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
|
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
|
||||||
|
@ -42,7 +42,8 @@ namespace SharedLibraryCore
|
|||||||
#endif
|
#endif
|
||||||
public static Encoding EncodingType;
|
public static Encoding EncodingType;
|
||||||
public static Layout CurrentLocalization = new Layout(new Dictionary<string, string>());
|
public static Layout CurrentLocalization = new Layout(new Dictionary<string, string>());
|
||||||
public static TimeSpan DefaultCommandTimeout { get; set; } = new TimeSpan(0, 0, 25);
|
|
||||||
|
public static TimeSpan DefaultCommandTimeout { get; set; } = new(0, 0, Utilities.IsDevelopment ? 360 : 25);
|
||||||
public static char[] DirectorySeparatorChars = { '\\', '/' };
|
public static char[] DirectorySeparatorChars = { '\\', '/' };
|
||||||
public static char CommandPrefix { get; set; } = '!';
|
public static char CommandPrefix { get; set; } = '!';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user