A client can register a callback function that is invoked when the Event Server receives a new event. The client does this with the function SPD_HandleEvent (see 7.8).
Since these events are reported asynchronously, the client must be event-driven. For clients running on UNIX systems, the function SPD_MainLoop (see 7.11) is provided for this purpose. For clients running on Windows systems, use the technique illustrated in 2.2.
Registering to Receive Events
The client program must register a callback routine for each type of event you want it to receive. Clients can register to receive the following types of events:
Alert events
Attribute change events
Delete object events
Log events
Typically, a client uses the SPD_HandleEvent function during its initialization phase to register a callback routine for each event it is to receive. Once the initialization has completed, and the callbacks have been registered, a UNIX client should call the function SPD_MainLoop.
In client programs on UNIX systems, the function SPD_MainLoop suspends the execution of the client program while waiting for an event to occur. When the Event Server receives an event for which the client has registered, the Event Server invokes the callback routine that was specified by SPD_HandleEvent.
If your client program has its own event loop, as Windows client programs typically do, the program must periodically interrupt its event loop and call function SPD_ProcessEvents to process SPD events. See 2.2 for illustration.
Data Structure of SPD_eventTP
The callback routine receives a description of the event in the data structure SPD_eventTP (see 8.1). This data structure has an area for data that is common to all events (for example, object class and object name) and a separate area for event-specific data. The latter area is a C union of data structures in which each data structure represents data that is specific to a single type of event. Since some events, such as SPD_attributeChangeEventCN, have variable amounts of data, a variable data area is provided in the event-specific area.