Add: Implement Commands for Chat Protocol

This commit is contained in:
Mathis Ginkel
2026-04-07 22:08:16 +02:00
parent 39f60c9113
commit 4e7b0ab67a
38 changed files with 644 additions and 439 deletions
@@ -0,0 +1,9 @@
package ch.unibas.dmi.dbis.cs108.casono.client.chat;
import javafx.application.Application;
public class Chat {
public static void main(String[] args) {
Application.launch(ChatApplication.class);
}
}
@@ -0,0 +1,48 @@
package ch.unibas.dmi.dbis.cs108.casono.client.chat;
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
import ch.unibas.dmi.dbis.cs108.casono.client.network.CoreClient;
import ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui.ChatBoxController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class ChatApplication extends Application {
private static final int SCENE_WIDTH = 1200;
private static final int SCENE_HEIGHT = 800;
String ip = "localhost";
String username = "mathis";
int port = 5000;
public ChatApplication() {}
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ui-structure/components/chatui/chatbox.fxml"));
ClientService clientService = new ClientService(ip, port);
CoreClient coreClient = new CoreClient(clientService);
// TODO login UI
coreClient.login(username);
ChatController chatController = new ChatController(username, clientService);
fxmlLoader.setControllerFactory(type -> {
if (type == ChatBoxController.class) {
return chatController.getChatBoxController();
} else {
try {
return type.getConstructor().newInstance();
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
});
Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
stage.setTitle("Chat");
stage.setScene(scene);
stage.show();
}
}
@@ -6,6 +6,6 @@ public class ChatTest {
@Test
public void chatTest() {
Client.main(new String[]{"mathis"});
}
}