Skip to content

Instantly share code, notes, and snippets.

@sudodoki
Created August 9, 2013 18:59
Show Gist options
  • Save sudodoki/6196204 to your computer and use it in GitHub Desktop.
Save sudodoki/6196204 to your computer and use it in GitHub Desktop.
var application_root = __dirname,
express = require("express"),
http = require('http'),
socket = require("socket.io");
var app = express();
var server = http.createServer(app)
var io = socket.listen(server);
io.sockets.on('connection', function(client){
console.log('Client connected...');
client.emit('message', {hello: 'world'})
client.on('messages', function(data){
console.log(data);
});
});
app.get('/', function(req, res){
res.sendfile(application_root + '/index.html');
});
console.log('listening on 8080');
server.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment