"Wrapper" Classes

To facilitate sending Signals to AlertGrid we have created simple wrapper classes for C++, C# and Java (download all). They all work in similar fashion: first you instantiate SignalGenerator class and then call one of the SendSignal()methods. Notice, that all the SendSignal() overloaded methods are synchronous (will get control back after the response is received from AlertGrid ). These wrapper classes are not guaranteed to be thread safe.

C++

SignalGenerator class wraps CURL ‘easy-interface’ functions to make HTTP request. It also takes care of url encoding and parses responses returned from AlertGrid. To use it, simply instantiate SignalGenerator object and then call one of the SendSignal()methods. An status code (enum) is returned.

string api_id = "4a19d491-d012-43c8-80a1-49a7e86ab814"; //your api ID, you can find it in Administration->Company settings
string receiverName = "myrcv"; //default Receiver

signalGenerator = new SignalGenerator(api_id, receiverName); 

/* Send signal with no parameters */
signalGenerator->SendSignal();

/* Send signal with no parameters, and retrieve saved signal ID */
int savedSignalID = 0;
signalGenerator->SendSignal(savedSignalID);

/* Send signal with no parameters, to some other receiver */
signalGenerator->SendSignal("myrcv_2");

/* Send signal with some custom parameters */
map params;
params["city"] = "Aspen";
params["temperature"] = "-5";
params["snow"] = "90.5";
params["measurment_time"] = "01/18/2008 14:34:01";
params["extra"] = "Sample string containing chars that should be url-encoded like whitespaces & = ? / \\ +";
signalGenerator->SendSignal(params);

/* Note, that SendSignal returns AGCode with result value */
AGCode result = signalGenerator->SendSignal();

C#

SignalGenerator class wraps other .NET classes used to send HTTP requests. It also takes care of url encoding and parses responses returned from AlertGrid. To use it, simply instantiate SignalGenerator object and then call one of the SendSignal() methods. An status code (enum) is returned.

string api_id = "3243c8ae-bfa3-4312-a226-1cf332d6bf0b"; //your AlertGrid API id
string receiverName = "myrcv"; //default Receiver

SignalGenerator signalGenerator = new SignalGenerator(api_id, receiverName);

/* Send signal with no parameters */
signalGenerator.SendSignal();

/* Send signal with no parameters, and retrieve saved signal ID */
int savedSignalID = 0;
signalGenerator.SendSignal(out savedSignalID);

/* Send signal with no parameters, to some other receiver */
signalGenerator.SendSignal("myrcv_2");

/* Send signal with some custom parameters */
IDictionary parameters = new Dictionary();
parameters.Add("city", "Aspen");
parameters.Add("temperature", "-5");
parameters.Add("snow", "90.5");
parameters.Add("measurment_time", "01/18/2008 14:34:01");
parameters.Add("extra", "Sample string containing chars that should be url-encoded like whitespaces & = ? / \\ +");
signalGenerator.SendSignal(parameters);

/* Note, that SendSignal returns AGCode with result value */
AGCode result = signalGenerator.SendSignal();

Java

SignalGenerator class wraps other java classes used to send HTTP requests. It also takes care of url encoding. SendSignal() method returns a string with AlertGrid response.

String api_id = "4a19d491-d012-43c8-80a1-49a7e86ab814"; //your API id, find it in Administration->Account Settings
String receiverName = "myrcv"; //default Receiver

SignalGenerator signalGenerator = new SignalGenerator(api_id, receiverName);

/* Send signal with no parameters. Response is returned as plain text */
signalGenerator.SendSignal();

/* Send signal with no parameters, to some other receiver */
signalGenerator.SendSignal("myrcv_2");

/* Send signal with some custom parameters */
Map parameters = new HashMap();
parameters.put("city","Aspen");
parameters.put("temperature", "-5");
parameters.put("snow", "90.5");
parameters.put("measurment_time", "01/18/2008 14:34:01");
parameters.put("extra", "Sample string containing chars that should be url-encoded like whitespaces & = ? / \\ +");
signalGenerator.SendSignal(parameters);