commit 23b716502233dc50fc42de0a8ee504b3cb5d8db0 Author: Piotr Dobrowolski Date: Thu Aug 9 11:33:03 2018 +0200 Initial minimal example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/index.html b/index.html new file mode 100644 index 0000000..bda0a50 --- /dev/null +++ b/index.html @@ -0,0 +1,122 @@ + + + + + + + + + diff --git a/signaling.js b/signaling.js new file mode 100644 index 0000000..04c518c --- /dev/null +++ b/signaling.js @@ -0,0 +1,24 @@ +var connect = require('connect'); +var http = require('http'); +var serveStatic = require('serve-static'); + +var app = connect(); + +app.use(serveStatic(__dirname)); + +var server = http.createServer(app); +var io = require('socket.io').listen(server); + +io.on('connection', function(socket) { + socket.on('join', function(room) { + console.info('join', room); + socket.join(room.room); + }); + + socket.on('message', function(data) { + console.info(data); + io.to(data.room).emit('message', data); + }); +}); + +server.listen(3000);