Skip to content

Commit

Permalink
Fixes for WebGUI #34
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltris committed May 16, 2020
1 parent b81e329 commit 60ea136
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions GK6X/WebGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class WebServer
public int Port { get; set; }
public bool IsRunning
{
get { return listener != null; }
get { return thread != null; }
}

Dictionary<string, Session> sessions = new Dictionary<string, Session>();
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 60ea136

Please sign in to comment.