Files
Testing/videocall2/server/ChatroomManager.js
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

31 lines
637 B
JavaScript

const Chatroom = require('./Chatroom')
const chatroomTemplates = require('../config/chatrooms')
module.exports = function () {
// mapping of all available chatrooms
const chatrooms = new Map(
chatroomTemplates.map(c => [
c.name,
Chatroom(c)
])
)
function removeClient(client) {
chatrooms.forEach(c => c.removeUser(client))
}
function getChatroomByName(chatroomName) {
return chatrooms.get(chatroomName)
}
function serializeChatrooms() {
return Array.from(chatrooms.values()).map(c => c.serialize())
}
return {
removeClient,
getChatroomByName,
serializeChatrooms
}
}