Common Cases, Subscription C++
Retrieving predefined attributes
Attribute filters
Discretionary attributes
Retrieving discretionary attributes
Common Cases, subscription code C
 |
 |
Attribute filters
defining subscriptions
All subscriptions filter content for at least one attribute. That attribute may be as simple as Message, or may be based on complex subscriber input.
In the first tutorial, we retrieved all attribute values associated with a channel for a particular subject. We can, however, also filter a notification's content.
To filter a notification's content for a particular predefined attribute, we assign it a value. In this example, we have assigned a value to the UserName attribute.
p.Subscribe("Sample.Chat","UserName==\"Jane\", new Subscriber1(),strdup("Listen to Jane"));
The subscriber might want to receive notifications published by other young women in the channel. Here, our subscriber could choose to filter notifications for Gender and Age.
p.Subscribe("Sample.Chat","( (Gender == 'F' or Gender == 'f') and Age <14)", new Subscriber1(),strdup("Girl Scouts"));
Note that the values in this subscription must conform to the data types set for the channel's attributes.
|