Esempio n. 1
0
        public void Start()
        {
            // Disable debug display from HttpServer
            _ws.SetDebug = false;

            // Register assemblies for content and refresh file list
            ((EmbeddedContent)_ws.HttpRootManager.GetSource("EmbeddedContent")).RegisterAssembly(this.GetType()); // Register it in specific source
            EmbeddedContent.RegisterAssembly(_ws, _wh.GetType());                                                 // Register it in all sources of matching type (helper method specific to this source)
            _ws.HttpRootManager.ReloadSourceFileList();                                                           // Reload all file lists in all sources

            // IP Filtering
            _ws.IPFilterEnabled = false;  // Change this to true to enable IP filter!
            _ws.IPFilter.AddBlackList(new IPAddress(new byte[] { 192, 168, 1, 64 }), 24);
            _ws.IPFilter.AddWhiteList(new IPAddress(new byte[] { 192, 168, 2, 64 }), 32);

            // User Authentication
            _ws.AuthenticationRequired = true;
            _ws.UserManager.AddUser("user", "password");

            // JSON
            _ws.AddPath("/data.json", _json.Listen);

            // Server root path for static content
            _ws.HttpRootManager.SetRootPath("PublicHtml");
            _ws.HttpRootManager.SetIndex(new string[] { "/index.html" });
            _ws.HttpRootManager.AddExtension("chtml", new DotLiquidCoreTemplate());
            _ws.HttpRootManager.AddExtension("shtml", new SimpleTemplate());

            // Initialize demos
            _cookieDemo.Start(_ws);
            _sessionDemo.Start(_ws);
            _LEDDemo.Start(_ws, _json, _template);
            _redirectDemo.Start(_ws);
            _temperatureDemo.Start(_ws);
            _timerDemo.Start(_ws, _json, _template);
            _templateDemo.Start(_ws, _template);
            _liquidDemo.Start(_ws);

            // Start server on default port (8000)
            //_ws.Start();
            _ws.Start("80");
        }