From 60ea13646dedc9b8d6011c9d5eaa401e8f8edcbb Mon Sep 17 00:00:00 2001 From: pixeltris <6952411+pixeltris@users.noreply.github.com> Date: Sat, 16 May 2020 15:50:36 +0100 Subject: [PATCH] Fixes for WebGUI #34 --- GK6X/WebGUI.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/GK6X/WebGUI.cs b/GK6X/WebGUI.cs index e8b7a9b..f1ec571 100644 --- a/GK6X/WebGUI.cs +++ b/GK6X/WebGUI.cs @@ -49,7 +49,7 @@ class WebServer public int Port { get; set; } public bool IsRunning { - get { return listener != null; } + get { return thread != null; } } Dictionary sessions = new Dictionary(); @@ -509,9 +509,12 @@ private void Process(HttpListenerContext context) driverValue = KeyValues.UnusedKeyValue; } } - if (keyIndex >= 0) + if (keyIndex >= 0 && keyIndex < driverValues.Length) { - Debug.WriteLine(device.State.KeysByLogicCode[keyIndex].KeyName + " = " + (DriverValue)driverValue); + if (device.State.KeysByLogicCode.ContainsKey(keyIndex)) + { + Debug.WriteLine(device.State.KeysByLogicCode[keyIndex].KeyName + " = " + (DriverValue)driverValue); + } driverValues[keyIndex] = driverValue; } } @@ -629,7 +632,7 @@ private void Process(HttpListenerContext context) if (!string.IsNullOrEmpty(basePath)) { string fullPath = Path.Combine(basePath, path); - Program.Log("WriteFile: " + fullPath); + //Program.Log("WriteFile: " + fullPath); if (IsFileInDirectoryOrSubDirectory(fullPath, dataPath)) { string dir = Path.GetDirectoryName(fullPath); @@ -863,9 +866,10 @@ private void Process(HttpListenerContext context) context.Response.OutputStream.Flush(); context.Response.StatusCode = (int)HttpStatusCode.OK; } - catch + catch (Exception e) { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; + Program.Log("WebGUI exception: " + e); } context.Response.OutputStream.Close();