Added Client Flushing its own messages (work only in terminal)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user