mirror of
https://git.battle-of-pip.de/root/vpr-mitarbeiterverwaltung.git
synced 2025-10-14 01:54:53 +02:00
trying to fix that some messages are not send after specific events
This commit is contained in:
@@ -14,15 +14,18 @@ public class CommandLibrary
|
||||
|
||||
#region Basic Commands
|
||||
|
||||
[Command("help")]
|
||||
public static string HelpCommand() =>
|
||||
"Available commands:\n" +
|
||||
"1. help - Show this help message\n" +
|
||||
"2. exit - Exit the server\n" +
|
||||
"3. user - User management\n" +
|
||||
"4. settings - Server settings\n" +
|
||||
"5. start - Start the server\n" +
|
||||
"6. stop - Stop the server\n";
|
||||
/*[Command("help")]
|
||||
public static string HelpCommand(string[] args, TcpClient? client, TcpServer? socket)
|
||||
{
|
||||
throw new CommandException("Available commands:%break" +
|
||||
"1. help - Show this help message%break" +
|
||||
"2. exit - Exit the server%break" +
|
||||
"3. user - User management%break" +
|
||||
"4. settings - Server settings%break" +
|
||||
"5. start - Start the server%break" +
|
||||
"6. stop - Stop the server%break");
|
||||
}*/
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
@@ -77,7 +77,7 @@ public void ExecuteCommand(string executor,
|
||||
};
|
||||
|
||||
var sendClientMessage = JsonSerializer.Serialize(returnMessage);
|
||||
clientSocket?.SendMessageAsync(client, sendClientMessage + "\n");
|
||||
clientSocket?.SendMessageAsync(client, sendClientMessage + "\r\n");
|
||||
Program.messageSender.Debug($"[COMMANDMANAGER] Response sent to client.");
|
||||
}
|
||||
// If your command threw a CommandException, catch it here:
|
||||
@@ -91,7 +91,15 @@ public void ExecuteCommand(string executor,
|
||||
Response = $"Error: {cmdEx.Message}"
|
||||
};
|
||||
var sendClientMessage = JsonSerializer.Serialize(returnMessage);
|
||||
clientSocket?.SendMessageAsync(client, sendClientMessage + "\n");
|
||||
try
|
||||
{
|
||||
clientSocket?.SendMessageAsync(client, sendClientMessage + "\r\n");
|
||||
Program.messageSender.Debug("[COMMANDMANAGER] Response sent to client.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Program.messageSender.Error($"[COMMANDMANAGER] Cannot send errormessage to Client: {e.Message}");
|
||||
}
|
||||
}
|
||||
// Any other exception inside the invoked method
|
||||
catch (TargetInvocationException ex)
|
||||
@@ -113,6 +121,13 @@ public void ExecuteCommand(string executor,
|
||||
else
|
||||
{
|
||||
Program.messageSender.Warn($"[COMMANDMANAGER] Unknown command '{executor}' received.");
|
||||
var returnMessage = new Library.Server.JsonResponse
|
||||
{
|
||||
Id = cid,
|
||||
Response = $"Unknown command '{executor}' received."
|
||||
};
|
||||
string sendClientMessage = JsonSerializer.Serialize(returnMessage);
|
||||
clientSocket.SendMessageAsync(client, sendClientMessage + "\r\n");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user