AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.4.4
AMPS C & C++ Client Reference

Welcome to the AMPS C & C++ client API reference.The AMPS C++ client is a fully-featured client that provides a high performance, convenient interface for working with AMPS. The AMPS C client, which the C++ client is built upon, provides a low-level API for working with AMPS.

These pages provide a detailed API reference. This API reference is meant to be used with the C/C++ Developer Guide, the AMPS Command Reference, and the AMPS User Guide. Detailed information on how to use AMPS and the AMPS Client is provided in the guides and reference. The API documentation provides information on the implementation details (for example, the exact function signatures) and general information to help you quickly remember what a given function does (or what a given value represents).

The guide is included with the Client distribution, or you can visit the C++ developer page on the 60East web site for more details.

Using the C++ client is simple:

#include <iostream>
int main(void)
{
AMPS::Client amps("myapp"); // Use a unique name for an actual application
try
{
amps.connect("tcp://localhost:9007/amps/json");
amps.logon();
for (auto msg : amps.subscribe("orders",
"/symbol LIKE 'ABCD'"))
{
std::cout << msg.getData() << std::endl;
}
} catch (AMPSException &e) {
std::cerr << e.what() << std::endl;
return -1;
}
return 0;
}

In this short sample, you can see the outline of a typical AMPS application. An application typically:

  • Constructs a AMPS::HAClient or AMPS::Client object
  • Provides connection (and, if necessary, authentication) information to the Client
  • Connects and logs on to AMPS

A subscriber then typically:

  • Issues one or more commands to AMPS (using the AMPS::Command object or the named convenience methods)
  • Responds to the results returned by AMPS (which are returned as instances of AMPS::Message)

A publisher then typically:

  • Registers a callback to receive publish failures
  • Retrieves information from an external source
  • Formats that information into the message payload, and publishes the message to AMPS (using the AMPS::Client.publish() function or a AMPS::Command)
  • In the event a publish fails, responds appropriately in the callback

Naturally, the outline above is extremely simplified, and ignores the options available for setting up a AMPS::HAClient or AMPS::Client, as well as the details of working with AMPS. The distribution includes a number of sample programs that provide simple implementations of common tasks, and the Developer Guide provides an overview of available options, common patterns and usage, as well as best practice advice for design and implementation of applications that use AMPS.

To help with learning, troubleshooting, and debugging, 60East includes full source in the Client distribution, available from the C++ developer page