|
PreCache NetInjector Documentation Center : PreCache NetInjector Application Development Common Cases, Publication C++ |
|
|
|
Common Cases, publication code C++ the full code sample for the Common Cases tutorial The sample for this tutorial presented more examples of setting attributes. While the process of publication is the same as in Basic Case, Publication C++, we have added statements for #include "PC_evn_Filter.hpp" #include "PC_evn_Proxy.hpp" #include <iostream> using namespace precache::event; using std::cerr; using std::endl; int main(int argc, char* argv[]) { try { //Create a proxy for the channel and client. Proxy p(40,3001); //Create a notification. Notification n1(p,"Sample.Chat"); //Set the values for predefined attributes. n1.SetPredefinedAttr( n1.SetPredefinedAttr("UserName","Jane"); n1.SetPredefinedAttr("Age",(PC_LONG)10); n1.SetPredefinedAttr("Gender",'F'); //Publish the notification. p.Publish(n1); //Create a second notification. Notification n2(p,"Sample.Chat"); //Set the values for predefined attributes. n2.SetPredefinedAttr("Message","Dolly Parton, I love you!"); n2.SetPredefinedAttr("UserName","Laurel"); n2.SetPredefinedAttr("Age",(PC_LONG)12); n2.SetPredefinedAttr("Gender",'f'); //Set a discretionary attribute's value. n2.AddDiscretionaryAttr("Interest","Country Music");
//Publish the second notification. p.Publish(n2); } catch (PCException &e) { cerr<<e.Message().String()<<endl; } } In the final tutorial chapter, Common Cases, Subscription C++, we will build the participating subscriber's application. |
|