Moved socketio

pull/528/head
Egil Moeller 2012-02-25 16:44:37 +01:00
parent db38a43fd7
commit cddf71f6fe
3 changed files with 51 additions and 44 deletions

View File

@ -103,49 +103,6 @@ async.waterfall([
app.listen(settings.port, settings.ip);
console.log("Server is listening at " + settings.ip + ":" + settings.port);
//init socket.io and redirect all requests to the MessageHandler
var io = socketio.listen(app);
//this is only a workaround to ensure it works with all browers behind a proxy
//we should remove this when the new socket.io version is more stable
io.set('transports', ['xhr-polling']);
var socketIOLogger = log4js.getLogger("socket.io");
io.set('logger', {
debug: function (str)
{
socketIOLogger.debug.apply(socketIOLogger, arguments);
},
info: function (str)
{
socketIOLogger.info.apply(socketIOLogger, arguments);
},
warn: function (str)
{
socketIOLogger.warn.apply(socketIOLogger, arguments);
},
error: function (str)
{
socketIOLogger.error.apply(socketIOLogger, arguments);
},
});
//minify socket.io javascript
if(settings.minify)
io.enable('browser client minification');
var padMessageHandler = require("./handler/PadMessageHandler");
var timesliderMessageHandler = require("./handler/TimesliderMessageHandler");
//Initalize the Socket.IO Router
socketIORouter = require("./handler/SocketIORouter");
socketIORouter.setSocketIO(io);
socketIORouter.addComponent("pad", padMessageHandler);
socketIORouter.addComponent("timeslider", timesliderMessageHandler);
callback(null);
}
]);

49
node/socketio.js Normal file
View File

@ -0,0 +1,49 @@
var settings = require('./utils/Settings');
var socketio = require('socket.io');
var socketIORouter = require("./handler/SocketIORouter");
var log4js = require('log4js');
var hooks = require("./pluginfw/hooks");
var padMessageHandler = require("./handler/PadMessageHandler");
var timesliderMessageHandler = require("./handler/TimesliderMessageHandler");
exports.expressCreateServer = function (hook_name, args, cb) {
//init socket.io and redirect all requests to the MessageHandler
var io = socketio.listen(args.app);
//this is only a workaround to ensure it works with all browers behind a proxy
//we should remove this when the new socket.io version is more stable
io.set('transports', ['xhr-polling']);
var socketIOLogger = log4js.getLogger("socket.io");
io.set('logger', {
debug: function (str)
{
socketIOLogger.debug.apply(socketIOLogger, arguments);
},
info: function (str)
{
socketIOLogger.info.apply(socketIOLogger, arguments);
},
warn: function (str)
{
socketIOLogger.warn.apply(socketIOLogger, arguments);
},
error: function (str)
{
socketIOLogger.error.apply(socketIOLogger, arguments);
},
});
//minify socket.io javascript
if(settings.minify)
io.enable('browser client minification');
//Initalize the Socket.IO Router
socketIORouter.setSocketIO(io);
socketIORouter.addComponent("pad", padMessageHandler);
socketIORouter.addComponent("timeslider", timesliderMessageHandler);
hooks.callAll("socketio", {"app": args.app, "io": io});
}

View File

@ -8,7 +8,8 @@
{ "name": "webaccess", "hooks": { "expressConfigure": "../webaccess:expressConfigure" } },
{ "name": "apicalls", "hooks": { "expressCreateServer": "../apicalls:expressCreateServer" } },
{ "name": "importexport", "hooks": { "expressCreateServer": "../importexport:expressCreateServer" } },
{ "name": "errorhandling", "hooks": { "expressCreateServer": "../errorhandling:expressCreateServer" } }
{ "name": "errorhandling", "hooks": { "expressCreateServer": "../errorhandling:expressCreateServer" } },
{ "name": "socketio", "hooks": { "expressCreateServer": "../socketio:expressCreateServer" } }
]
}