2014-11-03 52 views
3

想象一下,我们有许多生产者和一位消费者的场景。消费者订阅名为“consumerGroup”的频道组。每次制作人进入系统时,他都会将频道“Producer-ID-Channel”添加到consumerGroup,订阅该频道并发布消息。关于PubNub渠道组

由于消费者已经订阅了它所属的组,所以消费者是否自动订阅了此频道?即使制作人的频道在最初订阅该组的时间之后加入了该组,

回答

1

是的!所有客户端需要做的是订阅频道组,并且通过任何方式将频道添加/移除到频道组,客户端将接收它们。

在JavaScript中,如果你的消息回调的样子:

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

+0

发来的邮件通过consumersGroup通道,如何在消费者知道它来自哪个生产商通道?或者消费者不知道具体渠道的设计要点? – 2014-12-08 23:30:46

+0

你在哪个客户端? – Geremy 2014-12-09 00:42:01

+0

javascript ... 3.7.2 – 2014-12-09 02:27:52