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:
@@ -12,12 +12,18 @@ public class Server
|
||||
private StreamReader reader;
|
||||
private StreamWriter writer;
|
||||
private Action<string> onMessageReceived;
|
||||
private Action<string> onCommandReceived;
|
||||
|
||||
public Action<string> OnMessageReceived
|
||||
{
|
||||
get => onMessageReceived;
|
||||
set => onMessageReceived = value ?? throw new ArgumentNullException(nameof(value), "onMessageReceived cannot be null.");
|
||||
}
|
||||
public Action<string> OnCommandReceived
|
||||
{
|
||||
get => onCommandReceived;
|
||||
set => onCommandReceived = value ?? throw new ArgumentNullException(nameof(value), "onMessageReceived cannot be null.");
|
||||
}
|
||||
|
||||
private ConcurrentDictionary<string, TaskCompletionSource<string>> pendingRequests = new();
|
||||
|
||||
@@ -49,6 +55,7 @@ public class Server
|
||||
{
|
||||
if (message.StartsWith("{") && message.EndsWith("}"))
|
||||
{
|
||||
onCommandReceived?.Invoke(message);
|
||||
Console.WriteLine("Received: " + message);
|
||||
// Parse the JSON response
|
||||
var response = JsonSerializer.Deserialize<JsonResponse>(message);
|
||||
|
Reference in New Issue
Block a user