Publish subscribe architecture in Beebotte is the key enabler for real-time applications.
Beebotte client side API makes it easy to interact with beebotte in real time using websockets.
A client can subscribe to public or private resources as explained below. When the resource is written to (Write API) or published to (publish API) the client gets notified.
You can subscribe to a private resource as follows:
var bbt = new BBT('API_Key', {auth_endpoint: 'authentication_URL'}); /* Subscribing to private resource will automatically request read access permission */ bbt.subscribe({ channel: 'private-dev', //Note the 'private-' prefix resource: 'res', }, function(msg){ /* Do something here */ /* Will get here every time a new resource data is written or published */ });
You can subscribe to a public resource as follows:
var bbt = new BBT('API_KEY'); //Public resources do not require special permissions, they are open for everybody bbt.subscribe({ channel: 'dev', resource: 'res', }, function(msg){ /* Do something here */ /* Will get here every time a new resource data is written or published */ });