Fix (user could join a room twice) + Simon's request
Simon's request
This commit is contained in:
@@ -9,15 +9,13 @@ public class ChatApp {
|
||||
Server server = new Server(6665);
|
||||
Client client = new Client(new InetSocketAddress("localhost", 6665));
|
||||
|
||||
client.SendCreateRoom("Room1");
|
||||
client.RequestRoomList();
|
||||
client.SendChatMessage("Hello");
|
||||
client.SendCreateRoom("101");
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
while (true) {
|
||||
String message = scanner.nextLine();
|
||||
System.out.print("\033[1A"); // Déplacer le curseur une ligne vers le haut
|
||||
System.out.print("\r\033[2K"); // Effacer la ligne entière
|
||||
System.out.print("\033[1A");
|
||||
System.out.print("\r\033[2K");
|
||||
System.out.flush();
|
||||
client.visitMessage(message);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Server implements PacketHandler {
|
||||
}
|
||||
|
||||
public void joinRoom(String roomName, ServerConnexion connexion) throws SocketException {
|
||||
if(roomNames.containsKey(roomName)) {
|
||||
if(roomNames.containsKey(roomName) && !roomNames.get(roomName).contains(connexion)) {
|
||||
roomNames.get(roomName).add(connexion);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user