Skip to content

Commit e858cf0

Browse files
committed
Use socket io v4
1 parent f8a0930 commit e858cf0

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

settings.json.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@
535535
/*
536536
* Restrict socket.io transport methods
537537
*/
538-
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],
538+
"socketTransportProtocols" : ["polling", "websocket"],
539539

540540
"socketIo": {
541541
/*

settings.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@
535535
/*
536536
* Restrict socket.io transport methods
537537
*/
538-
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],
538+
"socketTransportProtocols" : ["polling", "websocket"],
539539

540540
"socketIo": {
541541
/*

src/node/hooks/express/socketio.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ exports.expressCreateServer = (hookName, args, cb) => {
5151
// there shouldn't be a browser that isn't compatible to all
5252
// transports in this list at once
5353
// e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling
54-
io = socketio({
55-
transports: settings.socketTransportProtocols,
54+
io = new socketio.Server({
55+
transports: settings.socketTransportProtocols
5656
}).listen(args.server, {
5757
/*
5858
* Do not set the "io" cookie.
@@ -106,14 +106,14 @@ exports.expressCreateServer = (hookName, args, cb) => {
106106
});
107107

108108
io.use((socket, next) => {
109-
socket.conn.on('packet', (packet) => {
109+
socket.conn.on('package', (packet) => {
110110
// Tell express-session that the session is still active. The session store can use these
111111
// touch events to defer automatic session cleanup, and if express-session is configured with
112112
// rolling=true the cookie's expiration time will be renewed. (Note that WebSockets does not
113113
// have a standard mechanism for periodically updating the browser's cookies, so the browser
114114
// will not see the new cookie expiration time unless it makes a new HTTP request or the new
115115
// cookie value is sent to the client in a custom socket.io message.)
116-
if (socket.request.session != null) socket.request.session.touch();
116+
if (packet.request.session != null) packet.request.session.touch();
117117
});
118118
next();
119119
});

src/node/utils/Settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ exports.ssl = false;
121121
/**
122122
* socket.io transport methods
123123
**/
124-
exports.socketTransportProtocols = ['xhr-polling', 'jsonp-polling', 'htmlfile'];
124+
exports.socketTransportProtocols = ["polling", "websocket"];
125125

126126
exports.socketIo = {
127127
/**

src/static/js/socketio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const connect = (etherpadBaseUrl, namespace = '/', options = {}) => {
1919
const baseUrl = new URL(etherpadBaseUrl, window.location);
2020
const socketioUrl = new URL('socket.io', baseUrl);
2121
const namespaceUrl = new URL(namespace, new URL('/', baseUrl));
22-
return io(namespaceUrl.href, Object.assign({path: socketioUrl.pathname}, options));
22+
return new io.Socket(namespaceUrl.href, Object.assign({path: socketioUrl.pathname}, options));
2323
};
2424

2525
if (typeof exports === 'object') {

src/tests/backend/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ exports.connect = async (res = null) => {
148148
if (res) {
149149
padId = res.req.path.split('/p/')[1];
150150
}
151-
const socket = io(`${exports.baseUrl}/`, {
151+
const socket = new io.Socket(`${exports.baseUrl}/`, {
152152
forceNew: true, // Different tests will have different query parameters.
153153
path: '/socket.io',
154154
// socketio.js-client on node.js doesn't support cookies (see https://git.io/JU8u9), so the

0 commit comments

Comments
 (0)