private void InvokeHandlers(IEnumerable <IHIEventHandler> handlers, IHIEventArgs eventArgs) { foreach (IHIEventHandler handler in handlers) { SafeFire(handler, eventArgs); } }
private void SafeFire(IHIEventHandler handler, IHIEventArgs eventArgs) { try { handler.Invoke(eventArgs); } catch (Exception e) { string dumpPath = CoreManager.ServerCore.DumpException(e); CoreManager.ServerCore.ConsoleManager.Error("Event Handler", "An unhandled exception from an event handler has been swallowed!"); CoreManager.ServerCore.ConsoleManager.Error("Event Handler", " An exception dump has been saved to " + dumpPath); } }
private void Fire(string eventName, IHIEventArgs eventArgs, Plugin plugin) { InvokeHandlers(GetEventHandlers(eventName), eventArgs); }
public void Shutdown(bool terminate = true) { lock (_bootInProgressLocker) { if (ConsoleManager == null) return; ConsoleManager.Warning("Core", "Shutting down IHI!"); if (CoreManager.ServerCore.OfficalEventFirer == null) return; IHIEventArgs eventArgs = new IHIEventArgs(); CoreManager.ServerCore.OfficalEventFirer.Fire("shutdown:before", eventArgs); CoreManager.ServerCore.OfficalEventFirer.Fire("shutdown:after", eventArgs); if (WebAdminManager == null) return; WebAdminManager.Stop(); Config = null; System.Console.Beep(4000, 100); System.Console.Beep(3500, 100); System.Console.Beep(3000, 100); System.Console.Beep(2500, 100); System.Console.Beep(2000, 100); System.Console.Beep(1500, 100); System.Console.Beep(1000, 100); } }