/// <summary> /// Call to open the server and start listening for communication from IFTTT. /// </summary> public void OpenServer() { try { server = new Crestron.SimplSharp.Net.Http.HttpServer(EthernetAdapterType.EthernetUnknownAdapter); server.Port = Port; CrestronConsole.PrintLine("IFTTT: Port #: " + Port); server.ServerName = "IFTTT Server"; server.OnHttpRequest += OnServerRequest; server.Open(); CrestronConsole.PrintLine("IFTTT: Server started on port " + Port); } catch (Exception ex) { CrestronConsole.PrintLine("IFTTT: Error occurred while starting server."); CrestronConsole.PrintLine("IFTTT: " + ex.Message); } try { client = new HttpsClient(); client.HostVerification = false; client.PeerVerification = false; client.KeepAlive = false; } catch (Exception ex) { CrestronConsole.PrintLine("IFTTT: Error occurred while creating client."); CrestronConsole.PrintLine("IFTTT: " + ex.Message); } }
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); } }; }