Created room.js#getUserRoom
This commit is contained in:
parent
74fb1f5918
commit
e5eb641b34
@ -11,6 +11,15 @@ module.exports.connectUserToRoom = (roomId, user) => {
|
|||||||
console.log(JSON.stringify(rooms));
|
console.log(JSON.stringify(rooms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.getUserRoom = (userId) => {
|
||||||
|
for (const roomId in rooms) {
|
||||||
|
const room = rooms[roomId];
|
||||||
|
const memberIndex = room.members.findIndex(member => member.id === userId);
|
||||||
|
|
||||||
|
if (memberIndex !== -1) return roomId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.disconnectUser = (userId) => {
|
module.exports.disconnectUser = (userId) => {
|
||||||
for (const roomId in rooms) {
|
for (const roomId in rooms) {
|
||||||
const room = rooms[roomId];
|
const room = rooms[roomId];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user