Fixed issues with creating/deleting connection messages.
This commit is contained in:
@@ -6,7 +6,7 @@ namespace HermesSocketServer.Requests
|
||||
public class DeleteConnection : IRequest
|
||||
{
|
||||
public string Name => "delete_connection";
|
||||
public string[] RequiredKeys => ["id"];
|
||||
public string[] RequiredKeys => ["name"];
|
||||
private ILogger _logger;
|
||||
|
||||
public DeleteConnection(ILogger logger)
|
||||
@@ -16,16 +16,16 @@ namespace HermesSocketServer.Requests
|
||||
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var connectionId = data["id"].ToString()!;
|
||||
var connectionName = data["name"].ToString()!;
|
||||
|
||||
var result = channel.Connections.Remove(connectionId);
|
||||
var result = channel.Connections.Remove(connectionName);
|
||||
if (result)
|
||||
{
|
||||
_logger.Information($"Deleted a connection by id [connection id: {connectionId}]");
|
||||
_logger.Information($"Deleted a connection by name [connection name: {connectionName}]");
|
||||
return Task.FromResult(RequestResult.Successful(null));
|
||||
}
|
||||
|
||||
_logger.Warning($"Connection Id does not exist [connection id: {connectionId}]");
|
||||
_logger.Warning($"Connection Name does not exist [connection name: {connectionName}]");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user