From 362015e709423fc31c82d765791cec97e7450843 Mon Sep 17 00:00:00 2001 From: louisa Date: Wed, 14 Jun 2023 20:56:42 +0200 Subject: [PATCH] soockkss --- app.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 6d8a4c7..8de1410 100644 --- a/app.js +++ b/app.js @@ -24,6 +24,7 @@ var io = require('socket.io')(server); //here we are listening to the data coming in from the modules, it's called node-data in the html io.on('connection', function(socket){ + console.log("A client connected!"); parser.on('data', function(data) { const msg = data.split(' '); @@ -31,12 +32,13 @@ var io = require('socket.io')(server); io.emit('node-data', data); }); - console.log('Node.js is listening!!'); - socket.on("blink", (arg, callback) => { - console.log('sending blink message'); - const message = "blink"; - io.send(message); - }); + + socket.on("message", (message) => { + console.log("Received message:", message); + if (message === "blink") { + io.emit("blink"); // Trigger the blink event to all connected clients + } + }); socket.on('chat message', (msg) => { console.log('[user]['+ socket.id + '][' + msg + ']');