Thanos
Thanos

Reputation: 854

Regarding PubNub Channel groups

Imagine a scenario where we have many producers and one consumer. The consumer subscribes to a channel group named "consumerGroup". Each time a producer enters the system, he adds the channel "Producer-ID-Channel" to the consumerGroup, subscribes to the channel and publishes a message.

Does the consumer gets automatically subscribed to this channel since he has already subscribed to the group it belongs to? Even if the producer's channel was added to the group after the time he initially subscribed to the group?

Upvotes: 3

Views: 570

Answers (1)

Geremy
Geremy

Reputation: 2445

Yes! All the client needs to do is subscribe to the channel group, and as channels are added/removed to the channel group by whatever means, the client will receive them.

On JavaScript, if your message callback looks like:

function cb(message, envelope, channel){
 /* message will contain the message
  envelope will contain the server-response, in which data like message and channel are
  derived from. 

  element 0 will be the current message in the callback cycle
  (also accessible via 'message')
  element 1 will be the timetoken of the server response
  element 2 will be the channel group name the message arrived on
  element 3 will be the actual channel within the channel group the msg arrived on */

}

geremy

Upvotes: 1

Related Questions