protected override void OnStart(string[] args) { base.OnStart(args); _pluginManager.Log("Connecting..."); _pluginManager.Connect(); _pluginManager.Log("... ok, we're good to go."); }
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) { } } }
public static void RunUntilAborted(this AcServerPluginManager pluginManager) { if (pluginManager == null) { throw new ArgumentNullException("pluginManager"); } var pluginManagerService = new RunPluginInConsoleServiceHelper(pluginManager); try { pluginManagerService.InteractiveStart(); // Important note: Everything until pluginManagerService.InteractiveStop() won't happen for the services, // so please do only place console-related stuff here var input = GetBlockingInput(); while (input != "x" && input != "exit" && pluginManager.IsConnected) { // Basically we're blocking the Main Thread until exit. // Ugly, but pretty easy to use by the deriving Plugin // To have a bit of functionality we'll let the server admin // type in commands that can be understood by the deriving plugin if (!string.IsNullOrEmpty(input)) { pluginManager.ProcessEnteredCommand(input); } input = GetBlockingInput(); } pluginManagerService.InteractiveStop(); } catch (Exception ex) { pluginManager.Log("Error in RunUntilAborted"); pluginManager.Log(ex); } finally { if (pluginManager.IsConnected) { pluginManager.Disconnect(); } pluginManager.Log("Disconnected..."); } }
void CheckVersion() { try { PluginManager.Log("Plugin Version " + MinoratingPlugin.PluginVersion); var serverVersion = _mrserver.GetVersion(); PluginManager.Log("Connection to server with version: " + serverVersion); if (serverVersion.Major > MinoratingPlugin.PluginVersion.Major) { PluginManager.Log("================================"); PluginManager.Log("================================"); PluginManager.Log("Version mismatch, minorating.com requires a newer version (" + serverVersion + " vs. " + MinoratingPlugin.PluginVersion + ")"); Environment.Exit(2); } } catch (Exception ex) { PluginManager.Log("Error connecting to the remote server :("); PluginManager.Log(ex); Environment.Exit(1); } }