master
louisa 1 year ago
parent 490ae3afbf
commit 362015e709

@ -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 + ']');

Loading…
Cancel
Save