node.js - How to get channelid in pubnub subscribe/or publish function? -


this subscribe code want channelid used this.channel in code got undefined. there way can channelid

pubnub.subscribe({     channel: changing dynamically,     presence: function (m) {         console.log(m)     },     message: function (m) {         console.log(m);         console.log("channel ==" + this.channel)     },     error: function (error) {         // handle error here         console.log(json.stringify(error));     } }) 

result: channel==undefined

looking @ the fine manual, should work:

pubnub.subscribe({     channel: changing dynamically,     presence: function (m) {         console.log(m)     },     message: function (m, env, channel) {         console.log(m);         console.log("channel ==" + channel)     },     error: function (error) {         // handle error here         console.log(json.stringify(error));     } }) 

in other words, channel passed argument message callback.

the reason this.channel being undefined message callback isn't called in context of object passed pubnub.subscribe().


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -