mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Migrate Socket.IO from Version 2 to Version 3 🚀 (#6152)
* feat :migrate socket.io 2 -> 3 * fix: backend test * fix: ts error * rm * reset the test timeout * Updated cli client. * Updated lock file. * Use updated load tester. --------- Co-authored-by: SamTV12345 <40429738+samtv12345@users.noreply.github.com>
This commit is contained in:
parent
47f0113fd7
commit
b2be2ca714
17 changed files with 265 additions and 321 deletions
|
@ -147,7 +147,6 @@ exports.connect = async (res = null) => {
|
|||
}
|
||||
const socket = io(`${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
|
||||
// express_sid cookie must be passed as a query parameter.
|
||||
query: {cookie: reqCookieHdr, padId},
|
||||
|
@ -172,7 +171,7 @@ exports.connect = async (res = null) => {
|
|||
*/
|
||||
exports.handshake = async (socket, padId, token = padutils.generateAuthorToken()) => {
|
||||
logger.debug('sending CLIENT_READY...');
|
||||
socket.send({
|
||||
socket.emit('message', {
|
||||
component: 'pad',
|
||||
type: 'CLIENT_READY',
|
||||
padId,
|
||||
|
@ -189,7 +188,7 @@ exports.handshake = async (socket, padId, token = padutils.generateAuthorToken()
|
|||
* Convenience wrapper around `socket.send()` that waits for acknowledgement.
|
||||
*/
|
||||
exports.sendMessage = async (socket, message) => await new Promise((resolve, reject) => {
|
||||
socket.send(message, (errInfo) => {
|
||||
socket.emit('message', message, (errInfo) => {
|
||||
if (errInfo != null) {
|
||||
const {name, message} = errInfo;
|
||||
const err = new Error(message);
|
||||
|
|
|
@ -32,7 +32,7 @@ const checkHook = async (hookName, checkFn) => {
|
|||
};
|
||||
|
||||
const sendMessage = (socket, data) => {
|
||||
socket.send({
|
||||
socket.emit('message', {
|
||||
type: 'COLLABROOM',
|
||||
component: 'pad',
|
||||
data,
|
||||
|
|
|
@ -38,6 +38,7 @@ describe(__filename, function () {
|
|||
res = await agent.get(`/p/${roPadId}`).expect(200);
|
||||
roSocket = await common.connect(res);
|
||||
await common.handshake(roSocket, roPadId);
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
|
|
|
@ -390,7 +390,7 @@ describe(__filename, function () {
|
|||
handleMessage(socket, message) { assert.fail('wrong handler called'); }
|
||||
}());
|
||||
socket = await common.connect();
|
||||
socket.send(want);
|
||||
socket.emit('message', want);
|
||||
assert.deepEqual(await got, want);
|
||||
});
|
||||
|
||||
|
@ -398,7 +398,7 @@ describe(__filename, function () {
|
|||
const AckErr = class extends Error {
|
||||
constructor(name, ...args) { super(...args); this.name = name; }
|
||||
};
|
||||
socket.send(message,
|
||||
socket.emit('message', message,
|
||||
(errj, val) => errj != null ? reject(new AckErr(errj.name, errj.message)) : resolve(val));
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue