using RegexBot.Services.SharedEventService;
namespace RegexBot;
partial class RegexbotClient {
private readonly SharedEventService _svcSharedEvents;
///
/// Delegate used for the event.
///
/// The incoming event instance.
public delegate Task IncomingSharedEventHandler(ISharedEvent ev);
///
/// Sends an object instance implementing to all modules and services
/// subscribed to the event.
///
///
/// This method is non-blocking. Event handlers are executed in their own thread.
///
public Task PushSharedEventAsync(ISharedEvent ev) => _svcSharedEvents.PushSharedEventAsync(ev);
///
/// This event is fired after a module or internal service calls .
///
///
/// Subscribers to this event are handled on a "fire and forget" basis and may execute on a thread
/// separate from the main one handling Discord events. Ensure that the code executed by the handler
/// executes quickly, is thread-safe, and throws no exceptions.
///
public event IncomingSharedEventHandler? SharedEventReceived {
add { lock (_svcSharedEvents) _svcSharedEvents.Subscribers += value; }
remove { lock (_svcSharedEvents) _svcSharedEvents.Subscribers -= value; }
}
}