Complete the code to create a new namespace using Socket.IO.
const io = require('socket.io')(server); const chatNamespace = io.of('[1]');
Namespaces in Socket.IO start with a slash, like /chat.
Complete the code to join a client socket to a room named 'lobby'.
io.on('connection', (socket) => { socket.[1]('lobby'); });
The method to join a room is join.
Fix the error in broadcasting a message to all clients in a room 'game'.
io.to('game').[1]('start', { msg: 'Game begins!' });
The correct method to send an event is emit.
Fill both blanks to create a namespace '/chat' and join a room 'general' inside it.
const chat = io.of('[1]'); chat.on('connection', (socket) => { socket.[2]('general'); });
Namespaces start with a slash, so '/chat' is correct. To join a room, use join.
Fill all three blanks to emit a message 'hello' to all clients in room 'room1' inside namespace '/news'.
const news = io.of('[1]'); news.to('[2]').[3]('message', 'hello');
Namespace is '/news', room is 'room1', and the method to send is 'emit'.
