Example #1
0
        public static void Configure()
        {
            if (Configured)
            {
                return;
            }

            DisplayRetroBoot();

            CommandUtility.Register("VNC", AccessLevel.Administrator, OnCoreCommand);

            OutgoingPacketOverrides.Init();
            ExtendedOPL.Init();

            DateTime now = DateTime.UtcNow;

            ToConsole(String.Empty);
            ToConsole("Compile action started...");

            TryCatch(CompileServices, ToConsole);
            TryCatch(CompileModules, ToConsole);

            Compiled = true;

            if (OnCompiled != null)
            {
                TryCatch(OnCompiled, ToConsole);
            }

            double time = (DateTime.UtcNow - now).TotalSeconds;

            ToConsole("Compile action completed in {0:F2} second{1}", time, (time != 1) ? "s" : String.Empty);

            now = DateTime.UtcNow;

            ToConsole(String.Empty);
            ToConsole("Configure action started...");

            TryCatch(ConfigureServices, ToConsole);
            TryCatch(ConfigureModules, ToConsole);

            Configured = true;

            if (OnConfigured != null)
            {
                TryCatch(OnConfigured, ToConsole);
            }

            time = (DateTime.UtcNow - now).TotalSeconds;

            ToConsole("Configure action completed in {0:F2} second{1}", time, (time != 1) ? "s" : String.Empty);

            ProcessINIT();

            EventSink.ServerStarted += () =>
            {
                EventSink.WorldSave += e =>
                {
                    TryCatch(Backup, ToConsole);
                    TryCatch(Save, ToConsole);
                };
                EventSink.Shutdown += e => TryCatch(Dispose, ToConsole);
                EventSink.Crashed  += e => TryCatch(Dispose, ToConsole);
            };
        }
Example #2
0
        public static void Configure()
        {
            if (Configured)
            {
                return;
            }

            DisplayRetroBoot();

            CommandUtility.Register("VNC", AccessLevel.Administrator, OnCoreCommand);

            OutgoingPacketOverrides.Init();
            ExtendedOPL.Init();

            var now = DateTime.UtcNow;

            ToConsole(String.Empty);
            ToConsole("Compile action started...");

            TryCatch(CompileServices, ToConsole);
            TryCatch(CompileModules, ToConsole);

            Compiled = true;

            InvokeByPriority(OnCompiled);

            var time = (DateTime.UtcNow - now).TotalSeconds;

            ToConsole("Compile action completed in {0:F2} second{1}", time, (time != 1) ? "s" : String.Empty);

            now = DateTime.UtcNow;

            ToConsole(String.Empty);
            ToConsole("Configure action started...");

            TryCatch(ConfigureServices, ToConsole);
            TryCatch(ConfigureModules, ToConsole);

            Configured = true;

            InvokeByPriority(OnConfigured);

            time = (DateTime.UtcNow - now).TotalSeconds;

            ToConsole("Configure action completed in {0:F2} second{1}", time, (time != 1) ? "s" : String.Empty);

            ProcessINIT();

            EventSink.ServerStarted += () =>
            {
                EventSink.WorldSave += e =>
                {
                    TryCatch(Backup, ToConsole);
                    TryCatch(Save, ToConsole);
                };
                EventSink.Shutdown += e => TryCatch(Dispose, ToConsole);
                EventSink.Crashed  += e => TryCatch(Dispose, ToConsole);
            };

            try
            {
                var crashed = typeof(EventSink).GetEventDelegates("Crashed");

                foreach (var m in crashed.OfType <CrashedEventHandler>())
                {
                    EventSink.Crashed -= m;
                }

                EventSink.Crashed += e => Crashed = true;

                foreach (var m in crashed.OfType <CrashedEventHandler>())
                {
                    EventSink.Crashed += m;
                }
            }
            catch (Exception x)
            {
                ToConsole(x);

                EventSink.Crashed += e => Crashed = true;
            }
        }