/// <summary>
        /// Processes a GET request.
        /// </summary>
        /// <param name="context">The context of the request.</param>
        private void ProcessGet(HttpCwsContext context)
        {
            Debug.WriteLine("Processing GET.");

            try
            {
                var html = string.Empty;
                var css  = string.Empty;
                using (var stream = Crestron.SimplSharp.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Evands.Pellucid.Resources.CwsConsoleTemplate.html"))
                {
                    using (var reader = new Crestron.SimplSharp.CrestronIO.StreamReader(stream, true))
                    {
                        html = reader.ReadToEnd();
                    }
                }

                using (var stream = Crestron.SimplSharp.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Evands.Pellucid.Resources.default.css"))
                {
                    using (var reader = new Crestron.SimplSharp.CrestronIO.StreamReader(stream, true))
                    {
                        css = reader.ReadToEnd();
                    }
                }

                context.Response.StatusCode = 200;
                var host     = context.Request.Url.Host;
                var protocol = useSecureWebsocket ? "wss://" : "ws://";
                html = html.Replace("{{ CSS }}", css).Replace("{{ PROTOCOL }}", protocol).Replace("{{ PORT }}", socketPort).Replace("{{ HOST }}", host);
                context.Response.Write(html, true);
            }
            catch (Exception ex)
            {
                Debug.WriteException(this, ex, "Exception while processing GET.");
                context.Response.StatusCode        = 500;
                context.Response.StatusDescription = string.Format("Internal Server Error - Exception encountered while retrieving Console Endpoint.<br/><br/>{0}", ex.ToString());
                context.Response.Write(context.Response.StatusDescription, true);
            }
        }
Beispiel #2
0
        static private List <string> ReadCCFTextIRFile(String filename)
        {
            List <string> irlist = new List <string>();

            if (!File.Exists(filename))
            {
                return(null);
            }

            string line = "";

            using (Crestron.SimplSharp.CrestronIO.StreamReader file = new Crestron.SimplSharp.CrestronIO.StreamReader(filename))
            {
                while ((line = file.ReadLine()) != null)
                {
                    var irarray = CCFtoGC(line);
                    if (irarray != null)
                    {
                        irlist.Add(irarray);
                    }
                }
            }
            return(irlist);
        }