Skip to content

Instantly share code, notes, and snippets.

@austinogilvie
Created February 16, 2013 23:37
Show Gist options
  • Select an option

  • Save austinogilvie/4969231 to your computer and use it in GitHub Desktop.

Select an option

Save austinogilvie/4969231 to your computer and use it in GitHub Desktop.
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
, Series = require('./series').Series;
app.use(require('connect').static(__dirname + '/public'))
server.listen(8080);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
function make_series() {
var series = [{
data: Series.create(),
label: "Series " + Series.randint(1,10).toString()
}];
return series
};
io.sockets.on('connection', function (socket) {
socket.emit('plot data', make_series() );
// push new data every 2 sec
setInterval(function(){
socket.emit('plot data', make_series() );
}, 2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment