mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-22 07:16:13 +01:00
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
var log4js = require('log4js');
|
|
var socketio = require('socket.io');
|
|
var settings = require('../../utils/Settings');
|
|
var socketIORouter = require("../../handler/SocketIORouter");
|
|
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});
|
|
}
|