mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
add ServerCommandRequestExecuteEvent implementation
This commit is contained in:
@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SharedLibraryCore.Events.Management;
|
||||
|
||||
public class NotifyAfterDelayCompleteEvent : ManagementEvent
|
||||
{
|
||||
public Delegate Action { get; init; }
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SharedLibraryCore.Events.Management;
|
||||
|
||||
public class NotifyAfterDelayRequestEvent : ManagementEvent
|
||||
{
|
||||
public int DelayMs { get; init; }
|
||||
public Action Action { get; init; }
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace SharedLibraryCore.Events.Server;
|
||||
|
||||
public class ServerCommandRequestExecuteEvent : GameServerEvent
|
||||
{
|
||||
public ServerCommandRequestExecuteEvent(string command, IGameServer server)
|
||||
{
|
||||
Command = command;
|
||||
Server = server;
|
||||
}
|
||||
|
||||
public string Command { get; init; }
|
||||
public int? DelayMs { get; init; }
|
||||
public int? TimeoutMs { get; init; }
|
||||
}
|
@ -38,6 +38,11 @@ public interface IGameServerEventSubscriptions
|
||||
/// </summary>
|
||||
static event Func<ClientDataUpdateEvent, CancellationToken, Task> ClientDataUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a command is requested to be executed on a game server
|
||||
/// </summary>
|
||||
static event Func<ServerCommandRequestExecuteEvent, CancellationToken, Task> ServerCommandExecuteRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a command was executed on a game server
|
||||
/// <value><see cref="ServerCommandExecuteEvent"/></value>
|
||||
@ -67,7 +72,7 @@ public interface IGameServerEventSubscriptions
|
||||
/// <value><see cref="ServerValueSetRequestEvent"/></value>
|
||||
/// </summary>
|
||||
static event Func<ServerValueSetCompleteEvent, CancellationToken, Task> ServerValueSetCompleted;
|
||||
|
||||
|
||||
static Task InvokeEventAsync(CoreEvent coreEvent, CancellationToken token)
|
||||
{
|
||||
return coreEvent switch
|
||||
@ -77,6 +82,7 @@ public interface IGameServerEventSubscriptions
|
||||
ConnectionInterruptEvent connectionInterruptEvent => ConnectionInterrupted?.InvokeAsync(connectionInterruptEvent, token) ?? Task.CompletedTask,
|
||||
ConnectionRestoreEvent connectionRestoreEvent => ConnectionRestored?.InvokeAsync(connectionRestoreEvent, token) ?? Task.CompletedTask,
|
||||
ClientDataUpdateEvent clientDataUpdateEvent => ClientDataUpdated?.InvokeAsync(clientDataUpdateEvent, token) ?? Task.CompletedTask,
|
||||
ServerCommandRequestExecuteEvent serverCommandRequestExecuteEvent => ServerCommandExecuteRequested?.InvokeAsync(serverCommandRequestExecuteEvent, token) ?? Task.CompletedTask,
|
||||
ServerCommandExecuteEvent dataReceiveEvent => ServerCommandExecuted?.InvokeAsync(dataReceiveEvent, token) ?? Task.CompletedTask,
|
||||
ServerValueRequestEvent serverValueRequestEvent => ServerValueRequested?.InvokeAsync(serverValueRequestEvent, token) ?? Task.CompletedTask,
|
||||
ServerValueReceiveEvent serverValueReceiveEvent => ServerValueReceived?.InvokeAsync(serverValueReceiveEvent, token) ?? Task.CompletedTask,
|
||||
@ -93,6 +99,7 @@ public interface IGameServerEventSubscriptions
|
||||
ConnectionInterrupted = null;
|
||||
ConnectionRestored = null;
|
||||
ClientDataUpdated = null;
|
||||
ServerCommandExecuteRequested = null;
|
||||
ServerCommandExecuted = null;
|
||||
ServerValueReceived = null;
|
||||
ServerValueRequested = null;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Models;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
@ -17,6 +18,23 @@ namespace SharedLibraryCore.Interfaces
|
||||
/// <param name="previousPenalty">previous penalty the kick is occuring for (if applicable)</param>
|
||||
/// <returns></returns>
|
||||
Task Kick(string reason, EFClient target, EFClient origin, EFPenalty previousPenalty = null);
|
||||
|
||||
/// <summary>
|
||||
/// Execute a server command
|
||||
/// </summary>
|
||||
/// <param name="command">Server command to execute</param>
|
||||
/// <param name="token"><see cref="CancellationToken"/></param>
|
||||
/// <returns>Collection of console command output lines</returns>
|
||||
Task<string[]> ExecuteCommandAsync(string command, CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Set value for server dvar
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the server value to set</param>
|
||||
/// <param name="value">Value of the server value</param>
|
||||
/// <param name="token"><see cref="CancellationToken"/></param>
|
||||
/// <returns></returns>
|
||||
Task SetDvarAsync(string name, object value, CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Time the most recent match ended
|
||||
|
@ -163,6 +163,8 @@ namespace SharedLibraryCore
|
||||
public int Port { get; protected set; }
|
||||
public int ListenPort => Port;
|
||||
public abstract Task Kick(string reason, EFClient target, EFClient origin, EFPenalty originalPenalty);
|
||||
public abstract Task<string[]> ExecuteCommandAsync(string command, CancellationToken token = default);
|
||||
public abstract Task SetDvarAsync(string name, object value, CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns list of all current players
|
||||
|
Reference in New Issue
Block a user