If you're talking about the custom game code? That's what you're "RoomMapper" room would basically do.
var ctfRoomInUseLookup = {};
var ctfRoomName = "ctfRoom";
// register Capture the flag rooms
for(var i = 0; i < 10; i++) {
uniqueCtfRoomName = ctfRoomName + i;
ctfRoomInUseLookup[uniqueCtfRoomName] = false;
gameServer.register(uniqueCtfRoomName, CTF)
}
gameServer.register("RoomMapper", RoomMapper, { ctfRoomInUseLookup })
then inside your RoomMapper class you can keep track of which rooms are in use then you can also have another lookup like
// might need to get from redis or database for each new connection if room doesnt stay persisted
customIdsToRoomId = {
"custom1": "ctfRoom0",
"cool_kid_room": "ctfRoom1",
}
if someone wants to create a room.. theres a lot of ways to do this just going to write some pseudo code real quick
requestCreateRoom(roomType, uniqueId) {
// room doesnt already exist for unique custom id
if(!(uniqueId in customIdsToRoomId)) {
// find room not in use
for(var key in ctfRoomInUseLookup) {
if(!(ctfRoomInUseLookup[key]) {
// found room that isnt being used
client.send({ msg: "CREATE_CUSTOM_GRANTED", roomId: key })
ctfRoomInUseLookup[key] = true;
customIdsToRoomId[uniqueId] = key;
}
}
}
then basically you can do something like when someone requests to connect to a custom id
if("custom1" in customIdsToRoomId) {
client.send({ msg: "FOUND_ROOM_REQUESTED", roomId: customIdsToRoomId["custom1"]
}
Youd need to add logic to manage what happens when a player leaves a room and stuff. Actually on second thought it wouldnt be able to work EXACTLY like my code... since rooms dont persist when theres no more users connected so youd basically have to hack "RoomMapper" room to stay persistent somehow or youd have to use Redis or some sort of database to get and edit the look up maps.
Hope that makes some sense. I really need to get back to my own code now lol
edit:Formatting