mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-08 16:05:05 -04:00
Added changes from other branch
This commit is contained in:
parent
b6eaba64d4
commit
0b48179415
10 changed files with 398 additions and 186 deletions
|
@ -5,7 +5,7 @@ const express = require('../express');
|
|||
const log4js = require('log4js');
|
||||
const proxyaddr = require('proxy-addr');
|
||||
const settings = require('../../utils/Settings');
|
||||
const socketio = require('socket.io');
|
||||
const {Server} = require('socket.io');
|
||||
const socketIORouter = require('../../handler/SocketIORouter');
|
||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||
const padMessageHandler = require('../../handler/PadMessageHandler');
|
||||
|
@ -51,35 +51,64 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
|||
// there shouldn't be a browser that isn't compatible to all
|
||||
// transports in this list at once
|
||||
// e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling
|
||||
io = new socketio.Server({
|
||||
transports: settings.socketTransportProtocols
|
||||
}).listen(args.server, {
|
||||
/*
|
||||
* Do not set the "io" cookie.
|
||||
*
|
||||
* The "io" cookie is created by socket.io, and its purpose is to offer an
|
||||
* handle to perform load balancing with session stickiness when the library
|
||||
* falls back to long polling or below.
|
||||
*
|
||||
* In Etherpad's case, if an operator needs to load balance, he can use the
|
||||
* "express_sid" cookie, and thus "io" is of no use.
|
||||
*
|
||||
* Moreover, socket.io API does not offer a way of setting the "secure" flag
|
||||
* on it, and thus is a liability.
|
||||
*
|
||||
* Let's simply nuke "io".
|
||||
*
|
||||
* references:
|
||||
* https://socket.io/docs/using-multiple-nodes/#Sticky-load-balancing
|
||||
* https://github.com/socketio/socket.io/issues/2276#issuecomment-147184662 (not totally true, actually, see above)
|
||||
*/
|
||||
// io = socketio({
|
||||
// transports: settings.socketTransportProtocols,
|
||||
// }).listen(args.server, {
|
||||
// /*
|
||||
// * Do not set the "io" cookie.
|
||||
// *
|
||||
// * The "io" cookie is created by socket.io, and its purpose is to offer an
|
||||
// * handle to perform load balancing with session stickiness when the library
|
||||
// * falls back to long polling or below.
|
||||
// *
|
||||
// * In Etherpad's case, if an operator needs to load balance, he can use the
|
||||
// * "express_sid" cookie, and thus "io" is of no use.
|
||||
// *
|
||||
// * Moreover, socket.io API does not offer a way of setting the "secure" flag
|
||||
// * on it, and thus is a liability.
|
||||
// *
|
||||
// * Let's simply nuke "io".
|
||||
// *
|
||||
// * references:
|
||||
// * https://socket.io/docs/using-multiple-nodes/#Sticky-load-balancing
|
||||
// * https://github.com/socketio/socket.io/issues/2276#issuecomment-147184662 (not totally true, actually, see above)
|
||||
// */
|
||||
// cookie: false,
|
||||
// maxHttpBufferSize: settings.socketIo.maxHttpBufferSize,
|
||||
// });
|
||||
|
||||
const io = new Server(args.server, {
|
||||
// * Do not set the "io" cookie.
|
||||
// *
|
||||
// * The "io" cookie is created by socket.io, and its purpose is to offer an
|
||||
// * handle to perform load balancing with session stickiness when the library
|
||||
// * falls back to long polling or below.
|
||||
// *
|
||||
// * In Etherpad's case, if an operator needs to load balance, he can use the
|
||||
// * "express_sid" cookie, and thus "io" is of no use.
|
||||
// *
|
||||
// * Moreover, socket.io API does not offer a way of setting the "secure" flag
|
||||
// * on it, and thus is a liability.
|
||||
// *
|
||||
// * Let's simply nuke "io".
|
||||
// *
|
||||
// * references:
|
||||
// * https://socket.io/docs/using-multiple-nodes/#Sticky-load-balancing
|
||||
// *
|
||||
cookie: false,
|
||||
// transports: settings.socketTransportProtocols,
|
||||
maxHttpBufferSize: settings.socketIo.maxHttpBufferSize,
|
||||
});
|
||||
|
||||
io.on('connect', (socket) => {
|
||||
io.on('connection', (socket) => {
|
||||
sockets.add(socket);
|
||||
socketsEvents.emit('updated');
|
||||
|
||||
// https://socket.io/docs/v3/faq/index.html
|
||||
const session = socket.request.session;
|
||||
session.connections++;
|
||||
session.save();
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
sockets.delete(socket);
|
||||
socketsEvents.emit('updated');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue