From f8bc4dec62727fe8de8c2e77587447ae54a9ef07 Mon Sep 17 00:00:00 2001 From: Arseniusz Date: Sat, 27 Jan 2024 23:39:07 +0300 Subject: [PATCH] fix: change commands for backward compat --- src/main.js | 4 ++-- src/notifier.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.js b/src/main.js index eacd94d..354d01e 100644 --- a/src/main.js +++ b/src/main.js @@ -8,7 +8,7 @@ const wss = new WebSocketServer({ port: 7000 }); wss.on("connection", (ws) => { const id = randomUUID(); const message = { - command: "clientConnected", + action: "clientConnected", data: { socket: ws, id, @@ -19,7 +19,7 @@ wss.on("connection", (ws) => { ws.on("close", () => { const message = { - command: "cliendDisconnected", + action: "cliendDisconnected", data: { id, }, diff --git a/src/notifier.js b/src/notifier.js index 47f9462..59baa90 100644 --- a/src/notifier.js +++ b/src/notifier.js @@ -19,7 +19,7 @@ function stopOnline(message) { function addClient({ data }) { const { socket, id } = data; this.clients.set(id, socket); - this.notifyOne(socket, { command: "setState", data: this.state }); + this.notifyOne(socket, { action: "setState", data: this.state }); } function deleteClient({ data }) { @@ -47,12 +47,12 @@ const notifier = { socket.send(messageStrinified); }, processMessage: function (message) { - const action = actions[message.command]; + const action = actions[message.action]; if (action) { action.call(this, message); - console.log("PERFORM ACTION", message.command); + console.log("PERFORM ACTION", message.action); } else { - console.log("no avaible command for state mutation", message.command); + console.log("no avaible command for state mutation", message.action); } }, };