示例#1
0
        private static void Cleanup()
        {
            Logger.WARN("Shutting down protocols manager");
            ProtocolManager.Shutdown();
            ProtocolManager.CleanupDeadProtocols();

            Logger.WARN("Shutting down I/O handlers manager");
            IOHandlerManager.ShutdownIOHandlers();
            IOHandlerManager.DeleteDeadHandlers();
            IOHandlerManager.Shutdown();

            Logger.WARN("Unregister and delete default protocol handler");
            ProtocolFactoryManager.UnRegisterProtocolFactory(_protocolFactory);

            Logger.WARN("Shutting down applications");
            ClientApplicationManager.Shutdown();

            Logger.WARN("Delete the configuration");

            _configFile = null;

            //Logger.WARN("Doing final OpenSSL cleanup");
            //CleanupSSL();

            Logger.WARN("Shutting down the logger leaving you in the dark. Bye bye... :(");
            Console.ReadKey();
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();
            IOHandlerManager.Initialize();
            var protocolFactory = new DefaultProtocolFactory();

            protocolFactory.RegisterProtocolFactory();
            ClientApp.RegisterApplication();
            listBox.ItemsSource = DownloadList;
            var _speedTimer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, _speedTimer_Elapsed, Dispatcher);

            _speedTimer.Start();
            ClientApp.RegisterAppProtocolHandler(ProtocolTypes.PT_OUTBOUND_RTMP, new BaseRTMPAppProtocolHandler(Variant.Get()));
        }
示例#3
0
        public static void Run()
        {
            Logger.INFO("\n{0}", _configFile.GetServicesInfo());
            Logger.INFO("GO! GO! GO! ({0})", Process.GetCurrentProcess().Id);
            IOHandlerManager.Stopwatch.Start();
            //new Action(ProtocolManager.Manage).BeginInvoke(null,null);
            while (IOHandlerManager.Pulse())
            {
                // IOHandlerManager.DeleteDeadHandlers();
                ProtocolManager.CleanupDeadProtocols();
                Thread.Sleep(100);
                //ProtocolManager.Manage();
            }

            IOHandlerManager.Stopwatch.Stop();
        }
        public static void Shutdown(BaseClientApplication pApplication)
        {
            //1. Get the list of all active protocols
            var protocols = ProtocolManager.ActiveProtocols;

            //2. enqueue for delete for all protocols bound to pApplication
            foreach (var p in protocols.Where(x => x.Value.Application != null && x.Value.Application.Id == pApplication.Id).Select(x => x.Value))
            {
                p.Application = null;
                p.EnqueueForDelete();
            }

            //1. Get the list of all active IOHandlers and enqueue for delete for all services bound to pApplication
            var handlers = IOHandlerManager.ActiveIoHandler;

            foreach (var h in handlers)
            {
                BaseProtocol pTemp = h.Value.Protocol;
                while (pTemp != null)
                {
                    if ((pTemp.Application != null) &&
                        (pTemp.Application.Id == pApplication.Id))
                    {
                        IOHandlerManager.EnqueueForDelete(h.Value);
                        break;
                    }
                    pTemp = pTemp.NearProtocol;
                }
            }

            handlers = IOHandlerManager.ActiveIoHandler;
            foreach (var h in handlers)
            {
                if (h.Value.Type == IOHandlerType.IOHT_ACCEPTOR && ((TCPAcceptor)h.Value).Application != null && ((TCPAcceptor)h.Value).Application.Id == pApplication.Id)
                {
                    IOHandlerManager.EnqueueForDelete(h.Value);
                }
            }
            //4. Unregister it
            ClientApplicationManager.UnRegisterApplication(pApplication);
        }
示例#5
0
        private static bool Initialize()
        {
            LoggingExtensions.Logging.Log.InitializeWith <LoggingExtensions.log4net.Log4NetLog>();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            _configFile.Log().Info("Server Start!");
            if (!_configFile.LoadConfigFile())
            {
                Logger.FATAL("Unable to load ConfigFile!");
                return(false);
            }

            Logger.INFO("Initialize I/O handlers manager");
            IOHandlerManager.Initialize();
            if (!_configFile.ConfigModules())
            {
                Logger.FATAL("Unable to configure modules");
                return(false);
            }
            Logger.INFO("Plug in the default protocol factory");
            _protocolFactory = new DefaultProtocolFactory();
            if (!_protocolFactory.RegisterProtocolFactory())
            {
                Logger.FATAL("Unable to register default protocols factory");
                return(false);
            }
            Logger.INFO("Configure factories");
            if (!_configFile.ConfigFactories())
            {
                Logger.FATAL("Unable to configure factories");
                return(false);
            }
            Logger.INFO("Configure acceptors");
            if (!_configFile.ConfigAcceptors())
            {
                Logger.FATAL("Unable to configure acceptors");
                return(false);
            }

            Logger.INFO("Configure instances");
            if (!_configFile.ConfigInstances())
            {
                Logger.FATAL("Unable to configure instances");
                return(false);
            }

            Logger.INFO("Start I/O handlers manager");
            IOHandlerManager.Start();

            Logger.INFO("Configure applications");
            if (!_configFile.ConfigApplications())
            {
                Logger.FATAL("Unable to configure applications");
                return(false);
            }

            //Logger.INFO("Install the quit signal");
            //installQuitSignal(QuitSignalHandler);

            return(true);
        }