Regarding PubNub Channel Groups

Imagine a scenario in which we have many producers and one consumer. The user subscribes to a channel group named Consumer Group. Every time a producer logs in, he adds the "Producer-ID-Channel" to the consumer group, subscribes to the channel, and publishes a message.

Is the user automatically subscribed to this channel because they have already subscribed to the group they belong to? Even if the producer's channel was added to the group after he originally subscribed to the group?

+3


source to share


1 answer


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

In JavaScript, if your post's callback looks like this:

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

+1


source







All Articles