Skip to content

Instantly share code, notes, and snippets.

@pivanov
Created June 17, 2015 10:38
Show Gist options
  • Save pivanov/9b8f9ceb98d9b94df454 to your computer and use it in GitHub Desktop.
Save pivanov/9b8f9ceb98d9b94df454 to your computer and use it in GitHub Desktop.
var app = require('express')();
var http = require('http').Server(app);
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 3000;
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
});
http.listen(server_port, server_ip_address);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment