Added Client Flushing its own messages (work only in terminal)

This commit is contained in:
Clément
2025-03-01 09:36:10 +01:00
parent 8f46e8dc91
commit aaf2e83b35
3 changed files with 6 additions and 3 deletions

View File

@@ -16,6 +16,9 @@ public class ChatApp {
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.flush();
client.visitMessage(message);
}
}

View File

@@ -14,8 +14,10 @@ public class Client {
private final ClientConnexion connexion;
public static void main(String[] args) {
String host = "localhost";
int port = 6665;
try {
Client client = new Client(new InetSocketAddress("192.168.199.131", 6665));
Client client = new Client(new InetSocketAddress(host, port));
Scanner scanner = new Scanner(System.in);
while(true) {
String message = scanner.nextLine();

View File

@@ -87,8 +87,6 @@ public class ClientConnexion implements PacketVisitor, PacketHandler{
@Override
public void visitPacket(RoomListPacket packet) {
// System.out.println("Handled room list !");
// throw new UnsupportedOperationException("Unimplemented method 'visitPacket'");
System.out.println("Rooms :");
for (String room : packet.getRoomNames()) {
System.out.println("\t" + room);