OA&M API for Linux Programming Guide — August 2005 15
2
2.Event Handling
This chapter provides information about receiving and handling asynchronous events that are
transmitted via the event notification framework.
For your application to receive events from the event notification framework you must follow these
steps:
1. Define and implement a class that is derived from the CEventHandlerAdaptor class.
2. Provide an implementation of the CEventHandlerAdaptor::HandleEvent( ) function.
3. Define an array of filters for use by the DlgAdminConsumer object using
DlgEventService::AdminConsumer::FilterCallbackAssoc. Each DlgAdminConsumer object
references an array of filters. The elements in the array determine the following:
the event handler that is associated with the DlgAdminConsumer object. The
implementation of the CEventHandlerAdaptor::HandleEvent() function is called
when one of the events that is included in the array is received.
the client data that is returned to the application after the associated event handler object
has been invoked.
the events that are allowed to pass to the DlgAdminConsumer object. If an event does not
have an element in the filter array, the event is discarded and the DlgAdminConsumer
object will not receive it.
whether the event filter is enabled or disabled.
4. Use the DlgAdminConsumer::DlgAdminConsumer( ) function to instantiate a consumer
object. A pointer to the array initialized in step 3 is used as a parameter for the function.
5. Call the DlgAdminConsumer::StartListening( ) function so that the consumer object can
begin monitoring its associated event notification channel for events. When the
DlgAdminConsumer::StartListening( ) function is called, the consumer object creates and
runs in its own thread, allowing it to monitor its associated event notification channel without
blocking the main application thread.
When a DlgAdminConsumer object receives an event through its associated event notification
channel, it compares the event’s msgId field to its filter array. If a matching filter is found, the
associated event handler object is invoked.
Note: When a DlgAdminConsumer object receives more than one event that is associated with the same
event handler object, the DlgAdminConsumer object must return from the
CEventHandlerAdaptor::HandleEvent() function before it can process the next event.