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 //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){ io.on('connection', function(socket){
console.log("A client connected!");
parser.on('data', function(data) { parser.on('data', function(data) {
const msg = data.split(' '); const msg = data.split(' ');
@ -31,12 +32,13 @@ var io = require('socket.io')(server);
io.emit('node-data', data); io.emit('node-data', data);
}); });
console.log('Node.js is listening!!');
socket.on("blink", (arg, callback) => { socket.on("message", (message) => {
console.log('sending blink message'); console.log("Received message:", message);
const message = "blink"; if (message === "blink") {
io.send(message); io.emit("blink"); // Trigger the blink event to all connected clients
}); }
});
socket.on('chat message', (msg) => { socket.on('chat message', (msg) => {
console.log('[user]['+ socket.id + '][' + msg + ']'); console.log('[user]['+ socket.id + '][' + msg + ']');

Loading…
Cancel
Save