From f91f43576828b6d8cbee941a7af8b1adf8761927 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 30 Sep 2025 12:11:25 -0600 Subject: [PATCH] fix: Add null check for CurrentScenario in MobileControlSystem This change introduces a check for `_roomCombiner.CurrentScenario` being `null`. When it is `null`, a `MobileControlMessage` is created with the type `/system/roomKey`, `clientId`, and `roomKey`, which is then sent to the client. This improves the handling of scenarios without a current scenario by ensuring relevant room key information is communicated. --- .../MobileControlSystemController.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs b/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs index 7994afc3..0579c1f6 100644 --- a/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs +++ b/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs @@ -2233,8 +2233,21 @@ namespace PepperDash.Essentials return; } + if (_roomCombiner.CurrentScenario == null) + { + var message = new MobileControlMessage + { + Type = "/system/roomKey", + ClientId = clientId, + Content = roomKey + }; + SendMessageObject(message); + return; + } + if (!_roomCombiner.CurrentScenario.UiMap.ContainsKey(roomKey)) { + this.LogWarning( "Unable to find correct roomKey for {roomKey} in current scenario. Returning {roomKey} as roomKey", roomKey);