Ejemplo n.º 1
0
        private static void Main()
        {
            try
            {

                IFileLog 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);
                    pluginManager.LoadInfoFromServerConfig();
                    pluginManager.AddPlugin(trackCycler);
                    pluginManager.LoadPluginsFromAppConfig();

                    // Some biolerplate to react to close window event, CTRL-C, kill, etc
                    _handler += new EventHandler(Handler);
                    SetConsoleCtrlHandler(_handler, true);

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

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

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

                    trackCycler.StopServer();
                }
                catch (Exception ex)
                {
                    logWriter.Log(ex);
                }
                logWriter.StopLoggingToFile();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
 internal void Initialize(AcServerPluginManager manager)
 {
     this.PluginManager = manager;
     this.OnInit();
 }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
 static void Main(string[] args)
 {
     AcServerPluginManager pluginManager = null;
     try
     {
         pluginManager = new AcServerPluginManager(new FileLogWriter("log", "minoplugin.txt") { CopyToConsole = true, LogWithTimestamp = true });
         pluginManager.LoadInfoFromServerConfig();
         pluginManager.AddPlugin(new MinoratingPlugin());
         pluginManager.LoadPluginsFromAppConfig();
         DriverInfo.MsgCarUpdateCacheSize = 10;
         pluginManager.RunUntilAborted();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         try
         {
             pluginManager.Log(ex);
         }
         catch (Exception){}
     }
 }
 public RunPluginInConsoleServiceHelper(AcServerPluginManager mgrToRun)
 {
     _pluginManager = mgrToRun;
 }