Skip to content

Instantly share code, notes, and snippets.

@Pingolus
Last active August 29, 2015 14:25
Show Gist options
  • Save Pingolus/344c95e0f398cf75767e to your computer and use it in GitHub Desktop.
Save Pingolus/344c95e0f398cf75767e to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
app.use(express.static(__dirname + '/public'));
app.get("/", function (req, res) {
res.sendFile(__dirname + '/public/chat.html');
});
io.on('connection', function (client) {
client.broadcast.emit('messageGeneral','Nouvelle connexion !');
client.on('nouveauPost', function (message) {
client.emit('messageGeneral', message);
client.broadcast.emit('messageGeneral', message);
});
});
server.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment