#include "Example.h"
#include <rda/Subscription.h>
class SimpleSubscription : public rdaSubscription
{
int counter;
public:
SimpleSubscription(const char* device,
const char* prop,
const char* cycle)
: rdaSubscription(device, prop, cycle, 0, false), counter(10) {}
virtual ~SimpleSubscription() {}
protected:
virtual void rejected(const rdaException& why)
{
cout << "REJECTED (" << why << ")\n";
delete this;
exit(1);
}
virtual void handleValue(const rdaData& value)
{
cout << value << "*****\n";
if (--counter == 0)
{
delete this;
exit(0);
}
}
virtual void handleError(const rdaIOError& err)
{
cout << err << "\n*****\n";
}
virtual void disconnected()
{
cout << "DISCONNECTED FROM DATA SOURCE\n";
}
virtual void reconnected()
{
cout << "RECONNECTED TO DATA SOURCE\n";
}
};
int main(int argc, char** argv)
{
setParameters(argc, argv);
try
{
new SimpleSubscription(deviceName, property, cycle);
sleepForever();
}
catch(const rdaException& ex)
{
cout << ex << endl;
}
catch(const rdaInternalError& ex)
{
cout << ex << endl;
}
return 0;
}