From 9416c492dd7454ced51b71ff3bc834c593c53d26 Mon Sep 17 00:00:00 2001 From: Riku Rouvila Date: Sat, 1 Nov 2014 22:06:01 +0200 Subject: [PATCH] add socket.io transports to configuration --- defaults/config.js | 9 ++++++++- src/server.js | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/defaults/config.js b/defaults/config.js index 26d9c095..dac8fc61 100644 --- a/defaults/config.js +++ b/defaults/config.js @@ -52,7 +52,7 @@ module.exports = { // @default true // autoload: true, - + // // Prefetch URLs // @@ -162,6 +162,13 @@ module.exports = { // join: "#foo, #shout-irc" }, + // + // Set socket.io transports + // + // @type array + // @default ['polling', 'websocket'] + // + transports: ['polling', 'websocket'] // // Run Shout with HTTPS support. diff --git a/src/server.js b/src/server.js index 36059f75..47876179 100644 --- a/src/server.js +++ b/src/server.js @@ -18,7 +18,7 @@ module.exports = function(options) { var app = express() .use(index) .use(express.static("client")); - + app.enable("trust proxy"); var server = null; @@ -26,6 +26,7 @@ module.exports = function(options) { var protocol = https.enable ? "https" : "http"; var port = config.port; var host = config.host; + var transports = config.transports || ['websocket', 'polling']; if (!https.enable){ server = require("http"); @@ -42,7 +43,10 @@ module.exports = function(options) { require("./identd").start(config.identd.port); } - sockets = io(server); + sockets = io(server, { + transports: transports + }); + sockets.on("connect", function(socket) { if (config.public) { auth.call(socket);