1abee4f9d7
./room.js:530995/86 ./server.js:530995/1413 ./package.json:530995/1484 ./views/room.handlebars:530995/1594
29 lines
478 B
JavaScript
29 lines
478 B
JavaScript
|
|
const rooms = {};
|
|
|
|
function getOrCreateRoom(roomId) {
|
|
let room = rooms[roomId];
|
|
|
|
if (!room) {
|
|
room = {
|
|
roomId: roomId,
|
|
participants: []
|
|
};
|
|
rooms[roomId] = room;
|
|
}
|
|
|
|
return room;
|
|
}
|
|
|
|
function addParticipant(roomId, participantId, participantName) {
|
|
let room = getOrCreateRoom(roomId);
|
|
|
|
room.participants.push({
|
|
participantId,
|
|
participantName,
|
|
});
|
|
|
|
rooms[roomId] = room;
|
|
}
|
|
|
|
module.exports = {getOrCreateRoom, addParticipant} |