PreCache NetInjector Documentation Center : PreCache NetInjector Application Development

Basic Case, Subscription — C++

   







Notification

— accessing the notification's content


When we published the notification, we set a value for a predefined attribute called Message. The subscriber must access this attribute of the channel.

The class definition creating the subscriber already included a reference to the notification:

Notify(Notification* pNotification, void* pClosure)

Each matching notification is passed to the application as the first argument of the Notify method. pNotification contains the contents of the notification's attributes.

The value of our predefined attribute Message was set to Hello World by the publisher (see Notification, Basic Case, Publication — C++).

GetPredefinedAttr retrieves the attribute value stored in the notification. This retrieval occurs within the Notify method.

pNotification->GetPredefinedAttr("Message",message);

cout<<"Incoming notification for
("<<(char*)pClosure<<"):"<<message<<endl;

The complete subscriber output should read:

Incoming notification for My First Subscription: Hello World.