diff --git a/index.js b/index.js index 5a7f955..7b574ef 100644 --- a/index.js +++ b/index.js @@ -7,12 +7,12 @@ const io = new Server(server); app.use(express.static('public')); -io.on('connection', (socket) => { - console.log('a user connected'); +io.on('connection', (socket) => { + console.log('a user connected'); //console log if a user connceted - socket.on('picture', (line) => { - console.log(line); - socket.broadcast.emit("dingdong",line); + socket.on('picture', (line) => { //if the message "picture" comes it will do this function. the message is called line + console.log(line); //logs the incoming message called line + socket.broadcast.emit("dingdong",line); //it broadcasts it to the other connected clients https://socket.io/docs/v4/tutorial/step-5 }); socket.on('disconnect', () => { @@ -20,6 +20,6 @@ io.on('connection', (socket) => { }); }); -server.listen(3000, () => { +server.listen(3000, () => { //if you would like to change the port change the number console.log('listening on *:3000'); }); diff --git a/public/index.html b/public/index.html index 5c55512..8ac6678 100644 --- a/public/index.html +++ b/public/index.html @@ -14,7 +14,7 @@