|
PreCache NetInjector Documentation Center : PreCache NetInjector Application Development Basic Case, Subscription C++ |
|
|
|
Basic Case, Subscription code C++ the complete subscription code The previous code samples presented the basics of subscription. A subscription application retrieves content in much the same way as it was published, albeit after first defining a subscription class. Here is the basic sequence of the subscription process:
#include "PC_evn_Filter.hpp" #include "PC_evn_Proxy.hpp" #include "PC_evn_Notification.hpp" #include "PC_evn_Subscriber.hpp" #include <iostream> using namespace precache::event; using std::cerr; using std::cout; using std::endl; //Define a subscriber class. class MySubscriber:public Subscriber { public: //Define the callback method. virtual void Notify( { PC_STRING message; //Retrieve the value of the predefined attribute. pNotification->GetPredefinedAttr( cout<<"Incoming notification for ( } }; int main(int argc, char* argv[]) { try { //Create a proxy for the channel and client. Proxy p(7,3002); //Submit the subscription. p.Subscribe( cout<<"Subscription was submitted... sleep(30); } catch (PCException &e) { cerr<<e.Message().String()<<endl; } } In the next chapter, Common Cases, Publication C++, we will learn more about attributes. |
|