diff --git a/package.json b/package.json index 79cbe0be..c2598cdb 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "cookie": "^1.0.1", "cookie-parser": "^1.4.4", "cors": "^2.8.5", - "emittery": "^1.2.0", + "emittery": "^2.0.0", "escape-string-regexp": "^5.0.0", "explain-error": "^1.0.4", "express": "^5.0.0", diff --git a/src/SocketServer.js b/src/SocketServer.js index edf90aac..9cf8d585 100644 --- a/src/SocketServer.js +++ b/src/SocketServer.js @@ -174,8 +174,8 @@ class SocketServer { port: options.server ? undefined : options.port, }); - this.#unsubscribe = uw.events.onAny((command, data) => { - this.#onServerMessage(command, data); + this.#unsubscribe = uw.events.onAny(({ name, data }) => { + this.#onServerMessage(name, data); }); this.#wss.on('error', (error) => { @@ -536,7 +536,7 @@ class SocketServer { connection.on('close', () => { this.remove(connection); }); - connection.on('authenticate', async ({ user, sessionID, lastEventID }) => { + connection.on('authenticate', async ({ data: { user, sessionID, lastEventID } }) => { const isReconnect = await connection.isReconnect(sessionID); this.#logger.info({ userId: user.id, isReconnect, lastEventID }, 'authenticated socket'); if (isReconnect) { @@ -565,7 +565,7 @@ class SocketServer { */ createAuthedConnection(socket, user, sessionID, lastEventID) { const connection = new AuthedConnection(this.#uw, socket, user, sessionID, lastEventID); - connection.on('close', ({ banned, lastEventID }) => { + connection.on('close', ({ data: { banned, lastEventID } }) => { if (banned) { this.#logger.info({ userId: user.id }, 'removing connection after ban'); disconnectUser(this.#uw, user.id); @@ -577,7 +577,7 @@ class SocketServer { }); connection.on( 'command', - ({ command, data }) => { + ({ data: { command, data } }) => { this.#logger.trace({ userId: user.id, command, data }, 'command'); if (has(this.#clientActions, command)) { // Ignore incorrect input diff --git a/src/plugins/configStore.js b/src/plugins/configStore.js index 590f2d20..85493b4c 100644 --- a/src/plugins/configStore.js +++ b/src/plugins/configStore.js @@ -57,7 +57,7 @@ class ConfigStore { fs.readFileSync(new URL('../schemas/definitions.json', import.meta.url), 'utf8'), )); - this.#unsubscribe = uw.events.on(CONFIG_UPDATE_MESSAGE, async (data) => { + this.#unsubscribe = uw.events.on(CONFIG_UPDATE_MESSAGE, async ({ data }) => { this.#logger.trace({ data }, 'handle config update'); try {