Skip to content

Instantly share code, notes, and snippets.

@MarkySparky
Created April 1, 2015 09:30
Show Gist options
  • Save MarkySparky/5885cb88e3f9fa9ed613 to your computer and use it in GitHub Desktop.
Save MarkySparky/5885cb88e3f9fa9ed613 to your computer and use it in GitHub Desktop.
Serves socket IO on express
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var grunt =require('grunt');
server.listen(9075);
app.get('/', function (req, res) {
res.send('Socket IO listnening');
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
console.log('got a new connectioon');
socket.emit('news', { hello: 'world' });
socket.on('requestPublish', function (data) {
console.log('requesting a publish');
console.log(data);
var cr = require('./create-yaml').cy;
console.log(cr);
cr(function(res){
console.log('Done' + res);
});
});
setTimeout(function(){
socket.emit('pub', { hello: 'publishing system' });
},2000)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment