mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
clean
This commit is contained in:
parent
150f5fc8c2
commit
7db3ad7a1e
3 changed files with 6 additions and 5 deletions
|
@ -1251,6 +1251,7 @@ const _getRoomSockets = (padID: string) => {
|
||||||
// it does here, but synchronously to avoid a race condition. This code will have to change when
|
// it does here, but synchronously to avoid a race condition. This code will have to change when
|
||||||
// we update to socket.io v3.
|
// we update to socket.io v3.
|
||||||
const room = ns.adapter.rooms?.get(padID);
|
const room = ns.adapter.rooms?.get(padID);
|
||||||
|
|
||||||
if (!room) return [];
|
if (!room) return [];
|
||||||
|
|
||||||
return Array.from(room)
|
return Array.from(room)
|
||||||
|
|
|
@ -94,6 +94,7 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
|
||||||
|
|
||||||
io.use(exports.socketSessionMiddleware(args));
|
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('/pluginfw/installer').use(exports.socketSessionMiddleware(args))
|
||||||
io.of('/settings').use(exports.socketSessionMiddleware(args))
|
io.of('/settings').use(exports.socketSessionMiddleware(args))
|
||||||
|
|
||||||
|
|
|
@ -21,20 +21,19 @@ const connect = (etherpadBaseUrl, namespace = '/', options = {}) => {
|
||||||
const namespaceUrl = new URL(namespace, new URL('/', baseUrl));
|
const namespaceUrl = new URL(namespace, new URL('/', baseUrl));
|
||||||
|
|
||||||
let socketOptions = {
|
let socketOptions = {
|
||||||
...options,
|
|
||||||
path: socketioUrl.pathname,
|
path: socketioUrl.pathname,
|
||||||
upgrade: true,
|
upgrade: true,
|
||||||
transports: ["websocket"]
|
transports: ["websocket"]
|
||||||
}
|
}
|
||||||
socketOptions = Object.assign(socketOptions, options);
|
socketOptions = Object.assign(options, socketOptions);
|
||||||
|
|
||||||
const socket = io(namespaceUrl.href, socketOptions);
|
const socket = io(namespaceUrl.href, socketOptions);
|
||||||
|
|
||||||
socket.on('connect_error', (error) => {
|
socket.on('connect_error', (error) => {
|
||||||
if (socket.io.engine.transports.indexOf('polling') === -1) {
|
if (socket.io.engine.transports.indexOf('polling') === -1) {
|
||||||
console.log('WebSocket connection failed. Falling back to long-polling.');
|
console.warn('WebSocket connection failed. Falling back to long-polling.');
|
||||||
socket.io.opts.transports = ['polling']; // Add polling transport
|
socket.io.opts.transports = ['polling'];
|
||||||
socket.io.engine.upgrade = false; // Disable further upgrades
|
socket.io.engine.upgrade = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue