mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-04-12 12:06:29 +00:00
fix: moved instantiation of server to resolve null ref exception
This commit is contained in:
parent
66c1b09510
commit
ba930dafaf
1 changed files with 17 additions and 14 deletions
|
|
@ -71,6 +71,8 @@ namespace PepperDash.Core.Web
|
||||||
Name = string.IsNullOrEmpty(name) ? DefaultName : name;
|
Name = string.IsNullOrEmpty(name) ? DefaultName : name;
|
||||||
BasePath = string.IsNullOrEmpty(basePath) ? DefaultBasePath : basePath;
|
BasePath = string.IsNullOrEmpty(basePath) ? DefaultBasePath : basePath;
|
||||||
|
|
||||||
|
if (_server == null) _server = new HttpCwsServer(BasePath);
|
||||||
|
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
|
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
|
||||||
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
|
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +156,13 @@ namespace PepperDash.Core.Web
|
||||||
{
|
{
|
||||||
_serverLock.Enter();
|
_serverLock.Enter();
|
||||||
|
|
||||||
if (_server != null)
|
if (_server == null)
|
||||||
|
{
|
||||||
|
Debug.Console(DebugInfo, this, "Server is null, unable to start");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsRegistered)
|
||||||
{
|
{
|
||||||
Debug.Console(DebugInfo, this, "Server has already been started");
|
Debug.Console(DebugInfo, this, "Server has already been started");
|
||||||
return;
|
return;
|
||||||
|
|
@ -162,11 +170,6 @@ namespace PepperDash.Core.Web
|
||||||
|
|
||||||
Debug.Console(DebugInfo, this, "Starting server");
|
Debug.Console(DebugInfo, this, "Starting server");
|
||||||
|
|
||||||
_server = new HttpCwsServer(BasePath)
|
|
||||||
{
|
|
||||||
HttpRequestHandler = new DefaultRequestRequestHandler()
|
|
||||||
};
|
|
||||||
|
|
||||||
IsRegistered = _server.Register();
|
IsRegistered = _server.Register();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -193,7 +196,7 @@ namespace PepperDash.Core.Web
|
||||||
|
|
||||||
if (_server == null)
|
if (_server == null)
|
||||||
{
|
{
|
||||||
Debug.Console(DebugInfo, this, "Server has already been stopped");
|
Debug.Console(DebugInfo, this, "Server is null or has already been stopped");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue