mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
Revise transport
Socket.io@3/4 (#6188)
* feat :migrate socket.io 2 -> 3 * fix: backend test * fix: ts error * rm * reset the test timeout * fix: socket transports * fix: ts * fix: merge * fix: merge * resolve merge * clean * clean
This commit is contained in:
parent
04cc3c8d54
commit
4887cd952a
4 changed files with 41 additions and 20 deletions
|
@ -957,6 +957,7 @@ const handleClientReady = async (socket:any, message: typeof ChatMessage) => {
|
|||
rev: pad.getHeadRevisionNumber(),
|
||||
time: currentTime,
|
||||
},
|
||||
socketTransportProtocols: settings.socketTransportProtocols,
|
||||
colorPalette: authorManager.getColorPalette(),
|
||||
clientIp: '127.0.0.1',
|
||||
userColor: authorColorId,
|
||||
|
|
|
@ -70,29 +70,30 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
|
|||
// 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 Server(args.server, {
|
||||
io = new Server({
|
||||
transports: settings.socketTransportProtocols,
|
||||
})
|
||||
|
||||
function handleConnection() {
|
||||
return (socket: any) => {
|
||||
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');
|
||||
});
|
||||
};
|
||||
}
|
||||
io.attach(args.server, {
|
||||
cookie: false,
|
||||
maxHttpBufferSize: settings.socketIo.maxHttpBufferSize,
|
||||
});
|
||||
|
||||
io.on('connection', handleConnection);
|
||||
io.on('connection', (socket:any) => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
io.use(exports.socketSessionMiddleware(args));
|
||||
|
||||
|
||||
// Temporary workaround so all clients go through middleware and handle connection
|
||||
io.of('/pluginfw/installer').use(exports.socketSessionMiddleware(args))
|
||||
io.of('/settings').use(exports.socketSessionMiddleware(args))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue