Purpose of Monitoring Event State Client
This example illustrates a client that monitors the state of the Event Server for specific events. The Event Server has various internal components that handle the routing of events. A client program can register a callback to track the availability of these internal components based upon the event type.
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)
{
//string caller = "Main()";
// Initialize the API.
// Application name = "event state example"
// No application qualifier.
m_spd.SPDInitClient("event state example", null);
// Monitor the state of alert events
m_spd.SPDMonitorEventState(SPD.SPD_eventType.SPD_alarmEvent,
new SPD.SPD_eventStateCallback(stateChgEventCB), null);
// Monitor the state of log events
m_spd.SPDMonitorEventState(SPD.SPD_eventType.SPD_logEvent, new
SPD.SPD_eventStateCallback(stateChgEventCB), null);
// Client enters event processing
Application.Run();
} // function: Main
// Callback which handles event state changes
static void stateChgEventCB(SPD.SPD_eventType type, // event type
SPD.SPD_eventStateType status, // event info
object passback)
{
switch (type)
{
case SPD.SPD_eventType.SPD_alarmEvent:
switch (status)
{
case SPD.SPD_eventStateType.SPD_eventUp:
// alert events are up, i.e., they may be sent and
// received.
break;
case SPD.SPD_eventStateType.SPD_eventDown:
// alert events are down, i.e., it is not possible to
// send or receive them.
break;
} // end of switch (status)
break;
case SPD.SPD_eventType.SPD_logEvent:
switch (status)
{
case SPD.SPD_eventStateType.SPD_eventUp:
// Log events are up, i.e., it is possible to log a
// message with Operations Sentinel logging.
break;
case SPD.SPD_eventStateType.SPD_eventDown:
// Log events are down, i.e., it is not possible to log
// a message with Operations Sentinel logging.
break;
} // end of switch (status)
break;
} // end of switch (type)
} // function: stateChgEventCB
} // class: MyProgram
}// namespace: ClientSampleProgram