diff options
author | Hakim El Hattab | 2015-09-29 10:38:34 +0200 |
---|---|---|
committer | Hakim El Hattab | 2015-09-29 10:38:34 +0200 |
commit | c1a7e83d75a917307320acfdcb87a5702109e979 (patch) | |
tree | d2a4b2bfeb71566def591b54671754d9a776e504 /plugin/multiplex/index.js | |
parent | b16bc6fc2e948dedf597004fb99e69d4042daa47 (diff) |
multiplexing work with socket.io 1.0+ #1281 #1276
Diffstat (limited to 'plugin/multiplex/index.js')
-rw-r--r-- | plugin/multiplex/index.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/plugin/multiplex/index.js b/plugin/multiplex/index.js index af058ed..40c1661 100644 --- a/plugin/multiplex/index.js +++ b/plugin/multiplex/index.js @@ -1,32 +1,32 @@ +var http = require('http'); var express = require('express'); var fs = require('fs'); var io = require('socket.io'); var crypto = require('crypto'); -var app = express.createServer(); -var staticDir = express.static; +var app = express(); +var staticDir = express.static; +var server = http.createServer(app); -io = io.listen(app); +io = io(server); var opts = { port: process.env.PORT || 1948, baseDir : __dirname + '/../../' }; -io.sockets.on('connection', function(socket) { - socket.on('slidechanged', function(slideData) { - if (typeof slideData.secret == 'undefined' || slideData.secret == null || slideData.secret === '') return; - if (createHash(slideData.secret) === slideData.socketId) { - slideData.secret = null; - socket.broadcast.emit(slideData.socketId, slideData); +io.on( 'connection', function( socket ) { + socket.on('multiplex-statechanged', function(data) { + if (typeof data.secret == 'undefined' || data.secret == null || data.secret === '') return; + if (createHash(data.secret) === data.socketId) { + data.secret = null; + socket.broadcast.emit(data.socketId, data); }; }); }); -app.configure(function() { - [ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) { - app.use('/' + dir, staticDir(opts.baseDir + dir)); - }); +[ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) { + app.use('/' + dir, staticDir(opts.baseDir + dir)); }); app.get("/", function(req, res) { @@ -47,7 +47,7 @@ var createHash = function(secret) { }; // Actually listen -app.listen(opts.port || null); +server.listen( opts.port || null ); var brown = '\033[33m', green = '\033[32m', |