Alert Recipient

Purpose of Alert Recipient Client

This example sets up the client to receive notification of alert events from the Event Server. Events might be sent as well as received by a single client. Refer to Section [xref text to replace] for other details which could be incorporated into this program.

Code

using System;
using Spo.SPDlib;
using System.Windows.Forms;
namespace ExamplesOfAPIUsage
{
    class MyAlertPrgram
    {
        // create a SPD class instance
        static SPD m_spd = new SPD();
        // Additional class member attributes declaration...
        [STAThread]
        static void Main(string[] args)
        {
            // Initialize the API.
            // Application name = "alert recipient example"
            // No application qualifier.
            m_spd.SPDInitClient("alert recipient example", null);
            // Register a callback to handle alert events.
            // No passback data is specified.
            m_spd.SPDHandleEvent(SPD.SPD_eventType.SPD_alarmEvent, 
               new SPD.SPD_eventCallback(alarmEventCB), null);
            // Client enters event processing
            Application.Run();
        } // function: Main
        // Callback which handles alert events
        static void alarmEventCB(SPD.SPD_eventType type, 	// event type
                      SPD.SPD_event this_event, 	// event info
                      object passback)
        {
            // Handle alert events
            if (type == SPD.SPD_eventType.SPD_alarmEvent)
            {
                SPD.SPD_alarmEvent alert = (SPD.SPD_alarmEvent)this_event.eventData;
                // Display data that is common to all events
                string.Format("class={0}  name={1}  appl={2}  applqual={3} 
                   severity={4} id={5}  qual={6}  text={7}", this_event.objectClass,
                   this_event.objectName, this_event.applicationName, 
                   this_event.applicationQualifier, alert.severity.ToString(), 
                   alert.alarmIdentifier, alert.alarmQualifier, alert.alarmText);
            } // alert event
            else
            {
                // If client only registered for alert event report, this is an 
                // error case, and may want to have error recovery steps.
                // If client registered for multiple event reports with the same 
                // callback function, process other event types 
            } // not alert event
        } // function: alarmEventCB
    } // class: MyProgram
}// namespace: ClientSampleProgram

Data Flow Diagram

This illustration shows the flow of information for the alert recipient client.