using HermesSocketServer.Models; using ILogger = Serilog.ILogger; namespace HermesSocketServer.Requests { public class DeleteConnection : IRequest { public string Name => "delete_connection"; public string[] RequiredKeys => ["id"]; private ILogger _logger; public DeleteConnection(ILogger logger) { _logger = logger; } public Task Grant(Channel channel, IDictionary data) { var connectionId = data["id"].ToString()!; var result = channel.Connections.Remove(connectionId); if (result) { _logger.Information($"Deleted a connection by id [connection id: {connectionId}]"); return Task.FromResult(RequestResult.Successful(null)); } _logger.Warning($"Connection Id does not exist [connection id: {connectionId}]"); return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache.")); } } }