Пример #1
0
 public MOTR_AdminWebsocket(Stream stream, TcpClient tcpClient, string header, IWebSocketLogger logger, MOTR_Sessions _sessions, MOTR_Dirs _dirs, MOTR_Users _users, MOTR_Admin _admin)
     : base(stream, tcpClient, header, true, logger)
 {
     _logger    = logger;
     m_Sessions = _sessions;
     m_Dirs     = _dirs;
     m_Users    = _users;
     m_Admin    = _admin;
 }
Пример #2
0
 //Stored when created classed
 public MOTR_Webserver(IWebSocketLogger logger, MOTR_Sessions sessions, MOTR_Users users, MOTR_Dirs dirs, MOTR_Queue queue, MOTR_Admin admin, MOTR_Downloads downloads)
 {
     _logger     = logger;
     _sessions   = sessions;
     _users      = users;
     _dirs       = dirs;
     _queue      = queue;
     _admin      = admin;
     _downloads  = downloads;
     pMe         = this; //Stored for the static calls
     aWebservers = new List <MOTR_WebserverObject>();
 }
Пример #3
0
        public MOTR_WebserverFactoryInitalWizard(string webRoot, MOTR_Users users, MOTR_Admin _admin, IWebSocketLogger logger)
        {
            _logger  = logger;
            _webRoot = string.IsNullOrWhiteSpace(webRoot) ? GetWebRoot() : webRoot;
            m_Users  = users;
            m_Admin  = _admin;

            if (!Directory.Exists(_webRoot))
            {
                _logger.Warning(this.GetType(), "InitalWizard: Web root not found: {0}", _webRoot);
            }
            else
            {
                _logger.Information(this.GetType(), "InitalWizard: Web root: {0}", _webRoot);
            }
        }
Пример #4
0
        public MOTR_WebserverFactory(string webRoot, MOTR_Sessions sessions, MOTR_Users users, MOTR_Dirs dirs, MOTR_Queue queue, MOTR_Admin _admin, MOTR_Downloads _downloads, IWebSocketLogger logger, MOTR_Webserver _webserver)
        {
            _logger     = logger;
            _webRoot    = string.IsNullOrWhiteSpace(webRoot) ? GetWebRoot() : webRoot;
            m_Sessions  = sessions;
            m_Users     = users;
            m_Dirs      = dirs;
            m_Queue     = queue;
            m_WebServer = _webserver;
            m_Admin     = _admin;
            m_Downloads = _downloads;

            if (!Directory.Exists(_webRoot))
            {
                _logger.Warning(this.GetType(), "Web root not found: {0}", _webRoot);
            }
            else
            {
                _logger.Debug(this.GetType(), "Web root: " + _webRoot);
            }
        }
Пример #5
0
        /// <SUMMARY>
        ///
        /// </SUMMARY>
        protected void ServiceMain()
        {
            //First of all, check the port is available
            if (IsPortOpen(iHTTP) == true)
            {
                LogEventError("Port for http " + iHTTP + " is already open, MOTR cannot run on this port");
                m_OnStopTimer.Start();
                return;
            }
            if (IsPortOpen(iHTTPS) == true)
            {
                LogEventError("Port for https " + iHTTPS + " is already open, MOTR cannot run on this port");
                m_OnStopTimer.Start();
                return;
            }

            //Here we are ready to go
            bool bSignaledThreadToStop = false;

            IWebSocketLogger _logger = new WebSocketLogger();
            //_logger.Information(typeof(WindowsService), "-----------------------------------------------------");
            //        private static MOTR_Webserver m_WebServerSSL;
            MOTR_Users     m_Users     = new MOTR_Users();
            MOTR_Sessions  m_Sessions  = new MOTR_Sessions(m_Users);
            MOTR_Dirs      m_Dirs      = new MOTR_Dirs();
            MOTR_Queue     m_Queue     = new MOTR_Queue();
            MOTR_Admin     m_Admin     = new MOTR_Admin();
            MOTR_Downloads m_Downloads = new MOTR_Downloads(m_Dirs);

            if (m_Admin.HasError)
            {
                _logger.Error(typeof(MOTR_Admin), m_Admin.GetErrorString());
            }
            MOTR_Webserver m_WebServer = new MOTR_Webserver(_logger, m_Sessions, m_Users, m_Dirs, m_Queue, m_Admin, m_Downloads);

            m_Queue.OnQueueProcentage    += m_WebServer.HandleEventUpdateProcentage;
            m_Queue.OnQueueUpdate        += m_WebServer.HandleEvent;
            m_Downloads.OnMobileDownload += m_WebServer.HandleEventSendMobileDownload;

            //Create the webserver
            //Note: HTTPS is only started when there are users available
#if DEBUG
            m_WebServer.CreateWebServer(iHTTP, @"..\..\WebFiles");
            if (iHTTPS > 0 && iHTTPS <= 0x0000FFFF)
            {
                m_WebServer.CreateWebServer(iHTTPS, @"..\..\WebFiles", true, @".\motrd.pfx", "");
            }
#else
            //Get directory where the motrd.exe file is located...
            string webDirectory = AppDomain.CurrentDomain.BaseDirectory;
            m_WebServer.CreateWebServer(iHTTP, webDirectory + @"WebFiles");
            if (iHTTPS > 0 && iHTTPS <= 0x0000FFFF)
            {
                m_WebServer.CreateWebServer(iHTTPS, webDirectory + @"WebFiles", true, webDirectory + @"motrd.pfx", "");
            }
#endif
            LogEventInformation("MOTRd everything created, program started...");
            _logger.Debug(typeof(WindowsService), "MOTRd everything created, program started git version...");

            //Wait forever for the shutdown event
            bSignaledThreadToStop = m_shutdownEvent.WaitOne(-1, true);

            _logger.Information(typeof(WindowsService), "--- ENDING -----------------------------------------------------");

            //Clear the queue items and let it run out of scope...
            m_Queue.ClearProcessListAndClean();
            _logger.Information(this.GetType(), "Finished with ClearProcessListAndClean()");
        }