Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
Working 1.0 with path option
<!doctype html>
<title>Socket.IO chat</title>
<form action="">
<input type="input" id="m" /><button>Send</button>
<pre id="output"></pre>
<script src=""></script>
<script src=""></script>
var socket = io('', { path: '/nfxplanner/'});
socket.on('connection', function (data) {
console.log("connected to socket server");
socket.on('message', function(msg){
console.log('message recieved from server ' + msg);
$("#output").append(msg + "\n");
var msg = $('#m').val() || "---";
socket.emit('message', "someone:" + msg);
console.log("message sent to server" + msg);
return false;
var app = require('express')();
var http = require('http').Server(app);
var io = require('')(http, { serveClient: true, path: '/nfxplanner/' });
app.get('/', function(req, res){
io.on('connection', function(socket){
console.log('a user connected!');
socket.on('disconnect', function(){
console.log('user disconnected!');
// emit incoming messages from client to Everyone!
socket.on('message', function(json){
io.emit('message', json);
http.listen(process.env.PORT || 8080, function(){
console.log('listening on ' + process.env.PORT || 8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.