I figured out that we had to enable Presence feature for each key on the PubNub dashboard for this to work. Silly thing I missed out..
Pubnub herenow not returning UUID list
-
05-07-2023 - |
Pregunta
I have recently started looking into pubnub, and I am trying to make pub-sub application using the same. I have my publisher in java and Subscriber in javascript.
Following is the publisher code in java:
Pubnub pubnub = new Pubnub("pub-c-key", "sub-c-key");
pubnub.hereNow("my_channel", cb);
In my Callable for hereNow I did a Sysout for response and i get the following response:
{"message":"OK","status":200,"uuids":[],"service":"Presence","occupancy":0}
Here is my JS code:
<script src=http://cdn.pubnub.com/pubnub.min.js ></script>
<script>(function(){
var pubnub = PUBNUB.init({
publish_key : 'pub-c-key',
subscribe_key : 'sub-c-key'
});
pubnub.subscribe({
channel : "my_channel",
message : function(m){ document.getElementById("my_item").innerHTML = m; },
connect : publish
});
function publish() {
pubnub.publish({
channel : "my_channel",
message : "Connected!"
});
}
})();</script>
But when I publish something to the channel, I get the result displayed on the webpage where the script is executed. pubnub.publish("my_channel","Offer!" , callback);
Why is the hereNow not working in my case? Any help or lead would do. I have read the pubnub documentation but I couldn't get it.
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow