Reputation: 877
I am using pubnub js sdk with pubnub's angular wrapper. I have been using the publish & subscribe methods for some time, and now it's time to integrate presence.
Problem is, when I follow the sample, the presence event fires continuously.
Seems to be coming from the pubnub.min.js rather than the angular wrapper.
$rootScope.$on(PubNub.ngPrsEv(self.channel), function (event, payload) {
console.log('Presence', payload);
self.users = PubNub.ngHereNow({ channel: self.channel });
console.log('Here now');
});
The event object being passed has a message of "OK", with the collection of uuids. Any ideas why this is happening?
G
Upvotes: 1
Views: 190
Reputation: 116
ngHereNow, as all pubnub calls, is asynchronoues and uses callbacks to pass results back to the caller.
PubNub.ngHereNow({ channel: <somechannel>, callback: function(cb){ //process results"}});
This is really a wrapper around the equivalent here_now call in the pubnub Javascript SDK, and works the same way. You can review the documentation for the javascript call:
https://www.pubnub.com/docs/web-javascript/api-reference#here_now
Upvotes: 1