mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
feat(loginSet): limitation des salons en fonction des loginSet
This commit is contained in:
parent
6daa8c2fad
commit
58093d48a4
3 changed files with 47 additions and 4 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue