Sample Agent - HP Xw460c - ProLiant - Blade Workstation User Manual

Remote graphics software 5.3.0 user guide
Hide thumbs Also See for Xw460c - ProLiant - Blade Workstation:
Table of Contents

Advertisement

10-3 Sample agent

The sample Windows agent presented below monitors the HPRemote event log and interprets its events.
Comments are included in the agent code showing where additional code would be added to determine if the
number of primary users has dropped to zero. If so, further code can be added to terminate applications on the
Sender. A number of design issues for the Windows agent are described in the next section.
The sample code is a fixed-polling Windows agent that reads and interprets the HPRemote event log. The agent
uses two functions:
1.
processEvent(eventServer, eventSource, dwEventNum)
open event log, read event dwEventNum, close event logTo
if a valid read, process recognized EventIDs, then return
2.
monitorEvents(eventServer, eventSource, seconds)
for a finite number of seconds (or infinite if seconds <= 0) do
open event log, read log length, close event log
if log has changed, processEvent(), else sleep for X ms.
To properly use the function monitorEvents(...), the following strings must be defined in the function call:
LPCTSTR eventServer: if string is defined as "\\\\yourservername", then the log is stored on a
remote server - if the string is empty (NULL), then the log is stored locally (note that four backlashes compiles
to two in a string constant).
LPCTSTR eventSource: the name of the target event generator, e.g., "rgreceiver"
The sample agent use Microsoft event logging functions such as OpenEventLog, ReadEventLog, and
CloseEventLog. For information on these functions, refer to the Event Logging Functions link highlighted in
Figure 9-4.
The sample agent is listed below. Where noted, user-specific code should be added. The agent header file,
RGSenderEvents.h, is installed with the RGS Sender and is located at:
C:\Program Files\Hewlett-Packard\Remote Graphics Sender\include\RGSenderEvents.h
#include <windows.h>
#include <stdio.h>
#include "RGSenderEvents.h"
#define BUFFER_SIZE 1024
#define EVENT_SERVER NULL
#define EVENT_SRC "rgsender"
BOOL processEvent(LPCTSTR eventServer, LPCTSTR eventSource, DWORD dwEventNum)
{
HANDLE h;
EVENTLOGRECORD *pevlr;
BYTE bBuffer[BUFFER_SIZE];
DWORD dwRead, dwNeeded;
BOOL result;
//
Open, read, close event log ===========================================
if ((h = OpenEventLog(eventServer, eventSource)) == NULL)
{
... report error status ...
return true;
}
%2 = USB device vendor ID
%3 = USB device product ID
Data: None
// safe EVENTLOGRECORD size for now
// remote server = "\\\\nodename";
// specifies specific event name source in
// HPRemote
local = NULL
Remote Application Termination 170

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents