This class, implemented on top of the basic device access facilities (see rdaDeviceHandle), provides a simple and easy to use API for creating and managing subscriptions. For example, all you need to do to subscribe to the CPS supercycle information (SCCHIST property of device CPS.TGM) is the following:
class CPSSupercycle : public rdaSubscription { public: CPSSupercycle() : rdaSubscription("CPS.TGM","SCCHIST", 0, 0, false) {} protected: virtual void handleValue(const rdaData& value) { cout << "\nLAST SUPERCYCLE\n" << value << endl; } virtual void handleError(const rdaIOError& err) { cout << err << endl; } }; void main() { CPSSupercycle cps; pause(); }
The ructor of an rdaSubscription object creates a subscription request and sends it to the data provider (device server). If the server confirmes the request, then the object will start to receive periodic subscription updates via <A HREF="#update>callback methods. Users can (and should) delete susbscriptions that are not needed anymore. If the server cannot be contacted immediately (e.g., is down or ureachable due to a network failure), then the object will repeat attempts to submit the request until it is #confirmed or #rejected by the server, or the subscription object is deleted.