質問

I had tried for one long day to publish message to 2 channels,..But i could make it..

When i trying to publish with one channel i getting the call back..But not in two channel.. What mistake did i made..

This is my code..

pubnub.subscribe({
    channel : channel_name1,
    connect : function() {
        Ti.API.info('Entered Chat...');
    },
    presence : function(m) {
        Ti.API.info('presence..' + JSON.stringify(m));
    },
    disconnect : function() {
         Ti.API.info("Connection Lost.");
    },
    reconnect : function() {
         Ti.API.info("And we're Back!")
    },
    callback : function(message) {
        Ti.API.info(message);
    },
    error : function() {
         Ti.API.info("Lost Connection !!");
    },

});

And Now i publishing like this..

    pubnub.publish({
        channel :[ channel_name1, channel_name2],
        message : {
            text : message,
        },
        callback : function(info) {
            if (!info[0])
                setTimeout(function() {
                    send_a_message(message);
                }, 2000);
        }
    });
}
役に立ちましたか?

解決

Multiplexing (using more than one channel) is supported for subscribe, not for publish. To publish to more than one channel, loop through your channel list, and publish to each individually, using forEach(), or similar.

geremy

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top