InspIRCd  3.0
Public Member Functions | Static Public Member Functions | List of all members
ClientProtocol::EventHook Class Referenceabstract

#include <clientprotocol.h>

Inheritance diagram for ClientProtocol::EventHook:
Events::ModuleEventListener dynamic_reference_base::CaptureHook

Public Member Functions

 EventHook (Module *mod, const std::string &name, unsigned int priority=Events::ModuleEventListener::DefaultPriority)
 
virtual void OnEventInit (const ClientProtocol::Event &ev)
 
virtual ModResult OnPreEventSend (LocalUser *user, const ClientProtocol::Event &ev, ClientProtocol::MessageList &messagelist)=0
 
- Public Member Functions inherited from Events::ModuleEventListener
 ModuleEventListener (Module *mod, const std::string &eventid, unsigned int eventprio=DefaultPriority)
 

Static Public Member Functions

static std::string GetEventName (const std::string &name)
 

Additional Inherited Members

- Static Public Attributes inherited from Events::ModuleEventListener
static const unsigned int DefaultPriority = 100
 

Detailed Description

Base class for client protocol event hooks. A protocol event hook is attached to a single event type. It has the ability to alter or block messages sent to users which belong to the event the hook is attached to.

Constructor & Destructor Documentation

◆ EventHook()

ClientProtocol::EventHook::EventHook ( Module mod,
const std::string &  name,
unsigned int  priority = Events::ModuleEventListener::DefaultPriority 
)
inline

Constructor.

Parameters
modOwner of the hook.
nameName of the event to hook.
priorityPriority of the hook. Determines the order in which hooks for the same event get called. Optional.

Member Function Documentation

◆ OnEventInit()

virtual void ClientProtocol::EventHook::OnEventInit ( const ClientProtocol::Event ev)
inlinevirtual

Called exactly once before an event is sent to any user. The default implementation doesn't do anything.

Parameters
evEvent being sent to one or more users.

◆ OnPreEventSend()

virtual ModResult ClientProtocol::EventHook::OnPreEventSend ( LocalUser user,
const ClientProtocol::Event ev,
ClientProtocol::MessageList &  messagelist 
)
pure virtual

Called for each user that may receive the event. The hook may alter the messages sent to the user and decide whether further hooks should be executed.

Parameters
userUser the message list is being prepared to be sent to.
evEvent associated with the messages.
messagelistList of messages to send to the user. The hook can alter this in any way it sees fit, for example it can replace messages, add new messages, etc. The list must not be empty when the method returns.
Returns
MOD_RES_PASSTHRU to run hooks after the called hook or if no hooks are after the called hook, send the messages in messagelist to the user. MOD_RES_DENY to not send any messages to the user and to not run other hooks, MOD_RES_ALLOW to send the messages in messagelist to the user and to not run other hooks.

The documentation for this class was generated from the following file: