/// <summary> /// Call to close the server and stop listening for communication from IFTTT. /// </summary> public void CloseServer() { if (server != null) { server.Close(); server.OnHttpRequest -= OnServerRequest; server.Dispose(); server = null; CrestronConsole.PrintLine("IFTTT: Disposed of the server."); } if (client != null) { client.Dispose(); client = null; } }
public void Start(int port) { // TEMP - this should be inserted by configuring class HttpServer = new Crestron.SimplSharp.Net.Http.HttpServer(); HttpServer.ServerName = "Cisco API Server"; HttpServer.KeepAlive = true; HttpServer.Port = port; HttpServer.OnHttpRequest += Server_Request; HttpServer.Open(); CrestronEnvironment.ProgramStatusEventHandler += (a) => { if (a == eProgramStatusEventType.Stopping) { HttpServer.Close(); Debug.Console(1, "Shutting down HTTP Server on port {0}", HttpServer.Port); } }; }