public static void Main (string[] args) { Log.Register (new ConsoleOutEventLog (80)); Log.Information ("Initializing application..."); HttpSocketClient.RegisterHttpProxyUse (false, false); // Don't look for proxies. Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => { e.Cancel = true; executing = false; }; // Object database setup DB.BackupConnectionString = "Data Source=controller.db;Version=3;"; DB.BackupProviderName = "Clayster.Library.Data.Providers.SQLiteServer.SQLiteServerProvider"; db = DB.GetDatabaseProxy ("TheController"); // Mail setup mailSettings = MailSettings.LoadSettings (); if (mailSettings == null) { mailSettings = new MailSettings (); mailSettings.Host = "Enter mailserver SMTP host name here."; mailSettings.Port = 25; mailSettings.Ssl = false; mailSettings.From = "Enter address of sender here."; mailSettings.User = "******"; mailSettings.Password = "******"; mailSettings.Recipient = "Enter recipient of alarm mails here."; mailSettings.SaveNew (); } SmtpOutbox.Host = mailSettings.Host; SmtpOutbox.Port = mailSettings.Port; SmtpOutbox.Ssl = mailSettings.Ssl; SmtpOutbox.From = mailSettings.From; SmtpOutbox.User = mailSettings.User; SmtpOutbox.Password = mailSettings.Password; SmtpOutbox.OutboxPath = "MailOutbox"; SmtpOutbox.Start (Directory.GetCurrentDirectory ()); // UPnP Interface upnpServer = new HttpServer (8080, 10, true, true, 1); Log.Information ("UPnP Server receiving requests on port " + upnpServer.Port.ToString ()); ssdpClient = new SsdpClient (upnpServer, 10, true, true, false, false, false, 30); stillImageCameras = new Dictionary<string, IUPnPService> (); subscriptions = new SortedDictionary<DateTime, Subscription> (); stateVariables = new Dictionary<string, Dictionary<string, string>> (); events = new UPnPEvents ("/events"); upnpServer.Register (events); ssdpClient.OnUpdated += NetworkUpdated; events.OnEventsReceived += EventsReceived; // Main loop Log.Information ("Initialization complete. Application started..."); try { #if USE_HTTP MonitorHttp (); #elif USE_COAP MonitorCoap (); #elif USE_MQTT MonitorMqtt (); #endif } catch (Exception ex) { Log.Exception (ex); } finally { Log.Information ("Terminating application."); Log.Flush (); Log.Terminate (); SmtpOutbox.Terminate (); ssdpClient.Dispose (); upnpServer.Dispose (); } }
public static void Main(string[] args) { Log.Register(new ConsoleOutEventLog(80)); Log.Information("Initializing application..."); HttpSocketClient.RegisterHttpProxyUse(false, false); // Don't look for proxies. Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => { e.Cancel = true; executing = false; }; // Object database setup DB.BackupConnectionString = "Data Source=controller.db;Version=3;"; DB.BackupProviderName = "Clayster.Library.Data.Providers.SQLiteServer.SQLiteServerProvider"; db = DB.GetDatabaseProxy("TheController"); // Mail setup mailSettings = MailSettings.LoadSettings(); if (mailSettings == null) { mailSettings = new MailSettings(); mailSettings.Host = "Enter mailserver SMTP host name here."; mailSettings.Port = 25; mailSettings.Ssl = false; mailSettings.From = "Enter address of sender here."; mailSettings.User = "******"; mailSettings.Password = "******"; mailSettings.Recipient = "Enter recipient of alarm mails here."; mailSettings.SaveNew(); } SmtpOutbox.Host = mailSettings.Host; SmtpOutbox.Port = mailSettings.Port; SmtpOutbox.Ssl = mailSettings.Ssl; SmtpOutbox.From = mailSettings.From; SmtpOutbox.User = mailSettings.User; SmtpOutbox.Password = mailSettings.Password; SmtpOutbox.OutboxPath = "MailOutbox"; SmtpOutbox.Start(Directory.GetCurrentDirectory()); // UPnP Interface upnpServer = new HttpServer(8080, 10, true, true, 1); Log.Information("UPnP Server receiving requests on port " + upnpServer.Port.ToString()); ssdpClient = new SsdpClient(upnpServer, 10, true, true, false, false, false, 30); stillImageCameras = new Dictionary <string, IUPnPService> (); subscriptions = new SortedDictionary <DateTime, Subscription> (); stateVariables = new Dictionary <string, Dictionary <string, string> > (); events = new UPnPEvents("/events"); upnpServer.Register(events); ssdpClient.OnUpdated += NetworkUpdated; events.OnEventsReceived += EventsReceived; // Main loop Log.Information("Initialization complete. Application started..."); try { #if USE_HTTP MonitorHttp(); #elif USE_COAP MonitorCoap(); #endif } catch (Exception ex) { Log.Exception(ex); } finally { Log.Information("Terminating application."); Log.Flush(); Log.Terminate(); SmtpOutbox.Terminate(); ssdpClient.Dispose(); upnpServer.Dispose(); } }