Presence detection in Beebotte provides an insight on resources subscriptions. It provides a real time stream of events to notify when:
join event
)leave event
)connected event
)Beebotte client side API makes it easy for a web page to listen to presence events of a resource by subscribing to that resource with the 'presence-'
prefix.
You can subscribe to presence events of a resource as follows:
var bbt = new BBT('API_KEY', {auth_endpoint: 'authentication_URL'}); /* Subscribing to presence resource will automatically request read access permission */ bbt.subscribe({ channel: 'presence-dev', //Note the 'presence-' prefix resource: 'res' }, function(err, evt){ /* Do something here */ });
The callback function has two parameters, the first indicates an error if it's not null, while the second is a JSON object with the following format:
Beebotte considers presence events as private resources that require explicit authentication to get subscribed to. You must always provide an authentication end-point when initializing the BBT
object if you consider subscribing to presence events.
You can unsubscribe from presence events of a resource as follows:
var bbt = new BBT('API_KEY', {auth_endpoint: 'authentication_URL'}); bbt.unsubscribe({channel: 'presence-dev', resource: 'res'});