/// <summary> /// schedule a plugin to be executed at each heartbeat /// </summary> /// <param name="plugin">the plugin to be scheduled</param> public override void SchedulePlugin(APlugin plugin) { if (!plugin.CanBeRun()) { return; } try { // the scheduler is called to run the plugin each heartbeat SchedulerService.Instance.ScheduleTask($"task_{plugin.Infos.FileName}", plugin.Heartbeat, () => { try { Run(plugin); Log.Instance?.Info($"{plugin.Infos.FileName} correctly executed."); } catch (Exception e) { Log.Instance?.Error($"{plugin.Infos.FileName} had a problem: {e.Message}"); } }); } catch (Exception e) { Log.Instance?.Error($"SchedulePlugin: {e.Message}"); } }
/// <summary> /// run a plugin depending it's type /// </summary> /// <param name="plugin">plugin to be executed</param> public void Run(APlugin plugin) { if (!plugin.CanBeRun()) { return; } switch (plugin.Type) { case PluginFileInfos.FileType.DLL: Executor.RunFromDLL(plugin); break; case PluginFileInfos.FileType.Script: Executor.RunFromScript(plugin); break; case PluginFileInfos.FileType.SharedObject: Executor.RunFromSO(plugin); break; } }