9.2. Event dispatchers

Once event watchers have been developed to inform, the events should be reported to someone somewhere. That is where the event dispatcher appears. They are components which are in charge of sending the event to the correct receiver using the wished transport, such as Jabber (XMPP),IRC or e-mail.

Create a new dispatcher must be a subclass of EBox::Event::Dispatcher::Abstract under the namespace EBox::Event::Dispatcher. The constructor must call the superclass constructor given the domain parameter to the parent constructor as watcher does.

The following methods are required to be overridden in order to have a dispatcher ready to send messages:

configured

Determines if the dispatcher is already configured to enable to send messages.

ConfigurationMethod

This method should return one of the following:

none

None configuration is required to have the dispatcher ready. E.g. Log dispatcher does not required any configuration.

model

In order to configure the dispatcher, a model which describes the configuration parameters is required. The model name is returned by ConfigureModel which must be overridden by those dispatchers that configure themselves with a model.

link

Dispatcher, in this case, is configured in a more complex way. So a URL link points to the where the configuration is made should be served. This link is provided by ConfigureURL which must be overridden by those dispatchers that configure themselves with a link. For example, to send messages to the control center is required to have the connection ready with it, that is done in a some non trivial steps which start at that link.

_enable

This method may be overridden to test whether the dispatcher is ready to send messages or not. For instance, you may configure your dispatcher to send messages to a Jabber user, but it is possible not to have access to the Jabber server or the jabber user does not exist. It assumes configured returns true. It must throw the EBox::Exceptions::External if the dispatcher is not ready to send messages.

send

Once the dispatcher is configured and ready to send messages, this method is called to send the appropriate message as EBox::Event.

_receiver and _name

They are protected method to show information about the dispatcher in the Configuration page at Events+Configure dispatchers. The former is the localized name for the event dispatcher and the latter is the receiver description.

Once it is developed and installed, you can configured at the configuration page at Events+Configure dispatchers. Then enable the events module if needed and finally "Save changes" to restart ebox-events module.