Complete the code to send a message to all connected clients using Socket.IO.
io.[1]('message', 'Hello clients!');
The emit method sends an event to all connected clients.
Complete the code to broadcast a message to all clients except the sender.
socket.[1].emit('message', 'Hello others!');
emit directly on socket sends only to sender.to without specifying a room.The broadcast property on the socket sends to all except the sender.
Fix the error in broadcasting a message to a specific room.
io.to([1]).emit('message', 'Hello room!');
socket.id instead of room name.broadcast instead of to().The to method requires the room name as a string.
Fill both blanks to broadcast a message to a room except the sender.
socket.[1].to([2]).emit('message', 'Hello others in room!');
emit instead of broadcast.socket.id instead of room name.Use broadcast to exclude sender and to('room1') to target the room.
Fill all three blanks to send a private message to a specific client.
io.sockets.sockets.get([1]).[2]('private', [3]);
broadcast instead of emit.Get the socket by ID, then emit the event with the message object.
