Created
April 1, 2015 09:30
-
-
Save MarkySparky/5885cb88e3f9fa9ed613 to your computer and use it in GitHub Desktop.
Serves socket IO on express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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