feat(loginSet): limitation des salons en fonction des loginSet

This commit is contained in:
Emi Boucly 2025-01-29 22:58:59 +01:00
parent 6daa8c2fad
commit 58093d48a4
3 changed files with 47 additions and 4 deletions

View file

@ -58,6 +58,7 @@ public class ChatServer {
roomMap = new RoomMap();
contactMap.loadDefaultContacts();
roomMap.loadDefaultRooms();
roomMap.setLoginSets();
}
public void close() throws IOException {
@ -305,10 +306,12 @@ public class ChatServer {
private void doListRoom(JSONObject content) {
if (contactMap.getContact(user.getLogin()).isConnected()) {
for (Room room: roomMap.values()) {
try {
send(new Event("ROOM", room.toJsonObject()).toJson());
} catch (IOException e) {
throw new IllegalStateException();
if (room.getLoginSet().contains(user.getLogin())) {
try {
send(new Event("ROOM", room.toJsonObject()).toJson());
} catch (IOException e) {
throw new IllegalStateException();
}
}
}
}