Distributed messaging for NodeJS.
npm install bigioCheckout the Java or the Python versions of BigIO.
json
"dependencies": {
"bigio" : "0.1.13"
}
`
Then type `npm install`
Usage
#### Basic Usage
Register a listener on a topic:
`javascript
var bigio = require('bigio');
bigio.initialize(function() {
bigio.addListener( {
topic: 'HelloWorld',
listener: function(message) {
console.log('Received a message');
console.log(message[0]);
}
});
});
`
Send a message on a topic:
`javascript
var bigio = require('bigio');
bigio.initialize(function() {
setInterval(function() {
bigio.send( {
topic: 'HelloWorld',
message: { content : 'HelloWorld' }
});
}, 1000);
});
`
#### BigIO and JQuery
To use BigIO messages to update a web app, I'd recommend using the awesome project socket.io.
This is necessary since the BigIO messages come to the Node.js server and not the browser. To bridge this
gap, we use socket.io.
Here's an example using Express, socket.io, and JQuery:
##### index.js
`javascript
var app = require('express');
var http = require('http').Server(app);
var io = require('socket.io');
var bigio = require('bigio');
var $ = require('jquery');
http.listen(3000, function() {
console.log('Listening on port 3000');
});
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
bigio.initialize(function() {
bigio.addListener( {
topic: 'HelloWorld',
listener: function(message) {
var messageStr = message[0];
io.emit('hello_world', { 'message': messageStr });
}
});
});
`
##### index.html
`html
BigIO Web App
``