From 32510bd67febea25cc0e7e653ad9f8050a1bf018 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Wed, 16 Jul 2025 12:34:05 +0200 Subject: [PATCH 1/2] Add SendMessageToAll method (#484) * Fix typo * Add SendMessageToAll method --- .../Helpers/NotificationSendHelper.cs | 2 +- .../Servers/Ws/SptWebSocketConnectionHandler.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/NotificationSendHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/NotificationSendHelper.cs index af7215f6..aae23e6e 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/NotificationSendHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/NotificationSendHelper.cs @@ -50,7 +50,7 @@ public class NotificationSendHelper( if (logger.IsLogEnabled(LogLevel.Debug)) { logger.Debug( - $"Send message for {sessionID} websocket not available, queuing into profile" + $"Send message for {sessionID} websocket not available, queueing into profile" ); } notificationService.Add(sessionID, notificationMessage); diff --git a/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs b/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs index afeaca44..d9191362 100644 --- a/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs +++ b/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs @@ -163,6 +163,17 @@ public class SptWebSocketConnectionHandler( } } + public void SendMessageToAll(WsNotificationEvent output) + { + lock (_socketsLock) + { + foreach (var sessionID in _sockets.Keys) + { + SendMessage(sessionID, output); // this currently serializes for every socket, might want to separate into sending already serialized data + } + } + } + public void SendMessage(string sessionID, WsNotificationEvent output) { try From 58068f7c6aeb1520551c7bde20cfc99581e063c8 Mon Sep 17 00:00:00 2001 From: chompDev <27521899+chompDev@users.noreply.github.com> Date: Wed, 16 Jul 2025 10:34:34 +0000 Subject: [PATCH 2/2] .NET Format Style Fixes --- .../Servers/Ws/SptWebSocketConnectionHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs b/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs index d9191362..8ef8d6a9 100644 --- a/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs +++ b/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs @@ -170,7 +170,7 @@ public class SptWebSocketConnectionHandler( foreach (var sessionID in _sockets.Keys) { SendMessage(sessionID, output); // this currently serializes for every socket, might want to separate into sending already serialized data - } + } } }