コード例 #1
0
        static void Main(string[] args)
        {
            AcServerPluginManager pluginManager = null;

            try
            {
                pluginManager = new AcServerPluginManager(new FileLogWriter("log", "minoplugin.txt")
                {
                    CopyToConsole = true, LogWithTimestamp = true,
                })
                {
                    AcServerKeepAliveIntervalSeconds = 60
                };

                pluginManager.LoadInfoFromServerConfig();
                pluginManager.AddPlugin(new MinoratingPlugin());
                pluginManager.LoadPluginsFromAppConfig();
                DriverInfo.MsgCarUpdateCacheSize = 100;

                pluginManager.RunUntilAborted();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                try
                {
                    pluginManager.Log(ex);
                }
                catch (Exception) { }
            }
        }
コード例 #2
0
        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
            RaceTimeACPlugin raceTimePlugin = new RaceTimeACPlugin();

            AcServerPluginManager pluginManager = new AcServerPluginManager();

            pluginManager.LoadInfoFromServerConfig();
            pluginManager.AddPlugin(raceTimePlugin);
            pluginManager.LoadPluginsFromAppConfig();
            pluginManager.Connect();

            parser           = new AssettoCorsaFileParser(raceTimePlugin);
            parser.FileAlive = true;
            Thread thread = new Thread(new ParameterizedThreadStart(StartFileParser));

            thread.Start(parser);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: rafffel/acplugins
 static void Main(string[] args)
 {
     try
     {
         AcServerPluginManager pluginManager = new AcServerPluginManager(new FileLogWriter(".", "log.txt")
         {
             CopyToConsole = true, LogWithTimestamp = true
         });
         pluginManager.LoadInfoFromServerConfig();
         pluginManager.AddPlugin(new Admin2ChatPlugin());
         pluginManager.LoadPluginsFromAppConfig();
         RunPluginInConsole.RunUntilAborted(pluginManager);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: MaxChal/SRSA.RaceTime
        static void Main(string[] args)
        {
            RaceTimeACPlugin raceTimePlugin = new RaceTimeACPlugin();

            AcServerPluginManager pluginManager = new AcServerPluginManager();

            pluginManager.LoadInfoFromServerConfig();
            pluginManager.AddPlugin(raceTimePlugin);
            pluginManager.LoadPluginsFromAppConfig();
            pluginManager.Connect();

            var parser = new AssettoCorsaFileParser(raceTimePlugin);

            parser.FileAlive = true;
            Thread thread = new Thread(new ParameterizedThreadStart(StartFileParser));

            thread.Start(parser);

            Console.ReadLine();
            parser.FileAlive = false;
            Console.ReadLine();
        }
コード例 #5
0
        private static void Main()
        {
            try
            {
                FileLogWriter logWriter = null;

                IConfigManager config = new AppConfigConfigurator();

                bool interactiveConsole = config.GetSettingAsInt("interactive_console", 0) == 1;

                if (config.GetSettingAsInt("log_to_console", 0) == 0)
                {
                    if (config.GetSettingAsInt("overwrite_log_file", 0) == 1)
                    {
                        logWriter = new FileLogWriter(
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "logs"),
                            "TrackCycle.log")
                        {
                            LogWithTimestamp = true
                        };
                    }
                    else
                    {
                        logWriter = new FileLogWriter(
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "logs"),
                            DateTime.UtcNow.ToString("yyyyMMdd_HHmmss") + "_Startup.log")
                        {
                            LogWithTimestamp = true
                        };
                    }
                }

                try
                {
                    trackCycler = new TrackCyclePlugin();

                    AcServerPluginManager pluginManager = new AcServerPluginManager(logWriter, config);
                    pluginManager.LoadInfoFromServerConfig();
                    pluginManager.AddPlugin(trackCycler);
                    pluginManager.LoadPluginsFromAppConfig();

                    if (!MonoHelper.IsLinux)
                    {
                        // Some boilerplate to react to close window event, CTRL-C, kill, etc
                        _handler += new EventHandler(Handler);
                        SetConsoleCtrlHandler(_handler, true);
                    }

                    trackCycler.StartServer();
                    Console.Out.WriteLine("Server running...");

                    if (interactiveConsole)
                    {
                        Console.Out.WriteLine("Write 'next_track' to cycle to the next track.");
                        Console.Out.WriteLine("Write 'exit' to shut the server down.");
                    }

                    while (true)
                    {
                        if (interactiveConsole)
                        {
                            string line = Console.ReadLine();
                            if (line.ToLower() == "exit")
                            {
                                break;
                            }
                            else if (line.ToLower() == "next_track")
                            {
                                trackCycler.NextTrackAsync(true);
                            }
                            else
                            {
                                pluginManager.BroadcastChatMessage(line);
                            }
                        }
                        else
                        {
                            Thread.Sleep(500);
                        }
                    }

                    trackCycler.StopServer();
                }
                catch (Exception ex)
                {
                    if (logWriter != null)
                    {
                        logWriter.Log(ex);
                    }
                    else
                    {
                        throw;
                    }
                }
                if (logWriter != null)
                {
                    logWriter.StopLoggingToFile();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }