Just want to understand why my pubnub javascript code does not receive a message from a channel. I can subscribe and publish, but if another browser sends a new publish message, the other browser can not receive the message. heres my code:
$(document).ready(function () {
var pubnub = PUBNUB.init({
subscribe_key: 'subscribe-key-here',
publish_key: 'publish-key-here'
});
pubnub.subscribe({
channel : "my-channel",
message : function(m){ console.log(m) },
callback : function (message) { console.log("callback: ", message)},
connect : function() {
console.log("Connected")
pubnub.publish({
channel: 'my_channel',
message: { "color" : "blue" },
callback : function(details) {
console.log(details)
}
});
},
disconnect : function() { console.log("Disconnected") },
reconnect : function() { console.log("Reconnected") },
error : function() { console.log("Network Error") },
restore : true
})
});
by the way this code is running/testing on my nodejs localhost server and in chrome and firefox browser.