Im starting out with node.js and socket.io.
I have 2 questions:
- When a room is empty, is it automatically destoyed unbtil recreated?
and if it is not destroyed automaticaly, does it take up much ressources on the server?
The room is automatically removed from the array and the nodeJSs' V8 Garbage Collector finished the job of completely removing the room from ram. You don't have to worry about any of that. Remember that all users are automatically put on a room on joining the server ( the socket.id named room ).
io.emit should be used when you want to send a message from the server to anyone and
socket.emit should be used when you want to send a message only to the sender. More information can be found on this answer: https://stackoverflow.com/a/40829919/7868639