Skip to content

Instantly share code, notes, and snippets.

@adamhalasz
Last active August 29, 2015 14:14
Show Gist options
  • Save adamhalasz/1cc6a549f6a0e950f73e to your computer and use it in GitHub Desktop.
Save adamhalasz/1cc6a549f6a0e950f73e to your computer and use it in GitHub Desktop.
Using socket.io with diet.js
// Diet Server
var server = require('diet')
var app = server()
app.listen(8000)
// Socket.io
var io = require('socket.io')(app.server) // <-- use app.server
// Listen on websocket connection
io.on('connection', function(socket){
console.log('a user connected');
});
// Now you can access socket.io from client side with:
// http://localhost:8000/socket.io/socket.io.js
{
"name": "diet.socket.io",
"dependencies": {
"diet" : "0.9.1",
"socket.io" : "1.3.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment