Last active
August 29, 2015 14:14
-
-
Save adamhalasz/1cc6a549f6a0e950f73e to your computer and use it in GitHub Desktop.
Using socket.io with diet.js
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
// 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 |
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
{ | |
"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