botsilo
v1.0.5
Published
Botsilo client
Downloads
4
Readme
Botsilo Node
Botsilo node.js client.
Example usage
Node
npm i botsilo
var Bot = require('botsilo');
var bot = new Bot('botId', 'botSk'); // default host 'mqtts://botsilo.com:8883'
bot.on('connect', () => {
console.log('connected to broker');
bot.follow(bot.id);
bot.info();
});
bot.on('close', () => {
console.log('disconnected from broker');
process.exit();
});
bot.on('message', (from, payload) => {
console.log('MESSAGE', from, JSON.stringify(payload, null, 2));
process.exit();
});
bot.on('error', (err) => {
console.log('ERROR', err.message);
});
bot.start();
Browser
<script src="https://s3.amazonaws.com/botsilo.com/dist/botsilo.js"></script>
<script>
var bot = new Bot('botId', 'botSk', 'wss://botsilo.com:4883');
bot.on('connect', () => {
console.log('connected to broker');
bot.follow(bot.id);
bot.info();
});
bot.on('close', () => {
console.log('disconnected from broker');
});
bot.on('message', (from, payload) => {
console.log('MESSAGE', from, JSON.stringify(payload, null, 2));
});
bot.on('error', (err) => {
console.log('ERROR', err.message);
});
bot.start();
</script>