Use socket io v4

socket47
SamTV12345 2023-07-24 21:47:02 +02:00
parent f8a0930b53
commit e858cf02ef
6 changed files with 9 additions and 9 deletions

View File

@ -535,7 +535,7 @@
/*
* Restrict socket.io transport methods
*/
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],
"socketTransportProtocols" : ["polling", "websocket"],
"socketIo": {
/*

View File

@ -535,7 +535,7 @@
/*
* Restrict socket.io transport methods
*/
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],
"socketTransportProtocols" : ["polling", "websocket"],
"socketIo": {
/*

View File

@ -51,8 +51,8 @@ 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 = socketio({
transports: settings.socketTransportProtocols,
io = new socketio.Server({
transports: settings.socketTransportProtocols
}).listen(args.server, {
/*
* Do not set the "io" cookie.
@ -106,14 +106,14 @@ exports.expressCreateServer = (hookName, args, cb) => {
});
io.use((socket, next) => {
socket.conn.on('packet', (packet) => {
socket.conn.on('package', (packet) => {
// Tell express-session that the session is still active. The session store can use these
// touch events to defer automatic session cleanup, and if express-session is configured with
// rolling=true the cookie's expiration time will be renewed. (Note that WebSockets does not
// have a standard mechanism for periodically updating the browser's cookies, so the browser
// will not see the new cookie expiration time unless it makes a new HTTP request or the new
// cookie value is sent to the client in a custom socket.io message.)
if (socket.request.session != null) socket.request.session.touch();
if (packet.request.session != null) packet.request.session.touch();
});
next();
});

View File

@ -121,7 +121,7 @@ exports.ssl = false;
/**
* socket.io transport methods
**/
exports.socketTransportProtocols = ['xhr-polling', 'jsonp-polling', 'htmlfile'];
exports.socketTransportProtocols = ["polling", "websocket"];
exports.socketIo = {
/**

View File

@ -19,7 +19,7 @@ const connect = (etherpadBaseUrl, namespace = '/', options = {}) => {
const baseUrl = new URL(etherpadBaseUrl, window.location);
const socketioUrl = new URL('socket.io', baseUrl);
const namespaceUrl = new URL(namespace, new URL('/', baseUrl));
return io(namespaceUrl.href, Object.assign({path: socketioUrl.pathname}, options));
return new io.Socket(namespaceUrl.href, Object.assign({path: socketioUrl.pathname}, options));
};
if (typeof exports === 'object') {

View File

@ -148,7 +148,7 @@ exports.connect = async (res = null) => {
if (res) {
padId = res.req.path.split('/p/')[1];
}
const socket = io(`${exports.baseUrl}/`, {
const socket = new io.Socket(`${exports.baseUrl}/`, {
forceNew: true, // Different tests will have different query parameters.
path: '/socket.io',
// socketio.js-client on node.js doesn't support cookies (see https://git.io/JU8u9), so the