botsilo

1.0.5 • Public • Published

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>

Readme

Keywords

none

Package Sidebar

Install

npm i botsilo

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

476 kB

Total Files

21

Last publish

Collaborators

  • gafo