Compare commits

..

6 Commits

Author SHA1 Message Date
Aviv Cohn
e003e4dc94 fix: move ChangeScenario outside of loop, remove the discard modifier 2026-03-20 13:43:51 -04:00
Aviv Cohn
e2cdb1238b fix: calls scenario in SetRoomCombinationScenario preventing null from breaking rendering 2026-03-20 12:42:00 -04:00
Neil Dorin
dab5484d6e Merge pull request #1342 from PepperDash/wsdebug-persistence
Unique Client IDs
2025-10-15 15:16:46 -04:00
Andrew Welker
5c35a3be45 fix: catch exceptions in handlers directly
Previously, any exceptions that were occuring in a hander's action were being swalled due to being off on another thread. Now, those exceptions are caught and printed out.
2025-10-15 14:03:17 -05:00
Andrew Welker
6cb98e12fa fix: use correct collection for program stop 2025-10-15 14:02:06 -05:00
Andrew Welker
608601990b docs: fix Copilot comments 2025-10-15 12:54:14 -05:00
9 changed files with 44 additions and 17 deletions

View File

@@ -445,8 +445,10 @@ namespace PepperDash.Essentials.Core
else
{
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to find partition with key: '{0}'", partitionState.PartitionKey);
}
}
}
// Activates the scenario to prevent _currentScenario from being null when starting in manual mode.
ChangeScenario(scenario);
}
else
{

View File

@@ -110,7 +110,9 @@ namespace PepperDash.Essentials
/// </summary>
public string SystemUrl; //set only from SIMPL Bridge!
///
/// <summary>
/// True if the Mobile Control Edge Server Websocket is connected
/// </summary>
public bool Connected => _wsClient2 != null && _wsClient2.IsAlive;
private IEssentialsRoomCombiner _roomCombiner;
@@ -2335,10 +2337,33 @@ namespace PepperDash.Essentials
foreach (var handler in handlers)
{
Task.Run(
() =>
handler.Action(message.Type, message.ClientId, message.Content)
);
Task.Run(async () =>
{
try
{
handler.Action(message.Type, message.ClientId, message.Content);
}
catch (Exception ex)
{
this.LogError(
"Exception in handler for message type {type}, ClientId {clientId}",
message.Type,
message.ClientId
);
this.LogDebug(ex, "Stack Trace: ");
}
}).ContinueWith(task =>
{
if (task.IsFaulted && task.Exception != null)
{
this.LogError(
"Unhandled exception in Task for message type {type}, ClientId {clientId}",
message.Type,
message.ClientId
);
this.LogDebug(task.Exception.GetBaseException(), "Stack Trace: ");
}
}, TaskContinuationOptions.OnlyOnFaulted);
}
break;

View File

@@ -8,14 +8,14 @@ using PepperDash.Essentials.AppServer.Messengers;
namespace PepperDash.Essentials.Touchpanel
{
/// <summary>
/// Messenger to handle
/// Messenger to handle Zoom status and control for a TSW panel that supports the Zoom Application
/// </summary>
public class ITswZoomControlMessenger : MessengerBase
{
private readonly ITswZoomControl _zoomControl;
/// <summary>
/// Create in instance of the <see cref="ITswZoomControlMessenger"/> class for the given device
/// Create an instance of the <see cref="ITswZoomControlMessenger"/> class for the given device
/// </summary>
/// <param name="key">The key for this messenger</param>
/// <param name="messagePath">The message path for this messenger</param>

View File

@@ -12,9 +12,9 @@ namespace PepperDash.Essentials
private static int nextClientId = 0;
/// <summary>
/// Get
/// Get the next unique client ID
/// </summary>
/// <returns></returns>
/// <returns>Client ID</returns>
public static int GetNextClientId()
{
nextClientId++;

View File

@@ -72,7 +72,7 @@ namespace PepperDash.Essentials.WebApiHandlers
public MobileControlDirectServer DirectServer => mcController.Config.DirectServer.EnableDirectServer ? new MobileControlDirectServer(mcController.DirectServer) : null;
/// <summary>
/// Create in instace of the <see cref="InformationResponse"/> class.
/// Create an instance of the <see cref="InformationResponse"/> class.
/// </summary>
/// <param name="controller"></param>
public InformationResponse(MobileControlSystemController controller)

View File

@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.WebSocketServer
public string ClientId { get; private set; }
/// <summary>
/// Initalize an instance of the <see cref="ConnectionClosedEventArgs"/> class.
/// Initialize an instance of the <see cref="ConnectionClosedEventArgs"/> class.
/// </summary>
/// <param name="clientId">client that's closing</param>
public ConnectionClosedEventArgs(string clientId)

View File

@@ -861,11 +861,11 @@ namespace PepperDash.Essentials.WebSocketServer
{
if (programEventType == eProgramStatusEventType.Stopping)
{
foreach (var client in UiClientContexts.Values)
foreach (var client in UiClients.Values)
{
if (client.Client != null && client.Client.Context.WebSocket.IsAlive)
if (client != null && client.Context.WebSocket.IsAlive)
{
client.Client.Context.WebSocket.Close(CloseStatusCode.Normal, "Server Shutting Down");
client.Context.WebSocket.Close(CloseStatusCode.Normal, "Server Shutting Down");
}
}

View File

@@ -74,7 +74,7 @@ namespace PepperDash.Essentials.WebSocketServer
/// </summary>
/// <param name="key">The unique key to identify this client</param>
/// <param name="id">The client ID used by the client for this connection</param>
/// <param name="token"></param>
/// <param name="token">The token associated with this client</param>
public UiClient(string key, string id, string token)
{
Key = key;

View File

@@ -25,7 +25,7 @@ namespace PepperDash.Essentials.WebSocketServer
/// Initialize an instance of the <see cref="Version"/> class
/// </summary>
/// <remarks>
/// the <see cref="ServerIsRunningOnProcessorHardware"/> property is set to true by default.
/// The <see cref="ServerIsRunningOnProcessorHardware"/> property is set to true by default.
/// </remarks>
public Version()
{