Feat: Add whisper chat functionality

Introduce recording of users connected to server, to show usernames as options for whisper chat.
This commit is contained in:
Mathis Ginkel
2026-04-12 00:19:34 +02:00
parent 48e6b51ad1
commit b2adeb7a56
5 changed files with 159 additions and 50 deletions
@@ -4,6 +4,6 @@ import javafx.application.Application;
public class Chat {
public static void main(String[] args) {
Application.launch(ChatApplication.class);
Application.launch(ChatApplication.class, args);
}
}
@@ -4,8 +4,13 @@ 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 java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
@@ -13,13 +18,14 @@ 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";
final int port = 5000;
public ChatApplication() {}
public void start(Stage stage) throws IOException {
List<String> params = getParameters().getRaw();
String ip = params.get(0);
int port = Integer.parseInt(params.get(1));
String username = params.get(2);
FXMLLoader fxmlLoader =
new FXMLLoader(
getClass().getResource("/ui-structure/components/chatui/chatbox.fxml"));
@@ -27,10 +33,10 @@ public class ChatApplication extends Application {
CoreClient coreClient = new CoreClient(clientService);
coreClient.login(username);
ChatController chatController = new ChatController(username, clientService);
ChatBoxController chatBoxController = new ChatBoxController(username, chatController);
ChatBoxController chatBoxController = chatController.getChatBoxController();
fxmlLoader.setController(chatBoxController);
Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
Parent node = fxmlLoader.load();
Scene scene = new Scene(node, SCENE_WIDTH, SCENE_HEIGHT);
stage.setTitle("Chat");
stage.setScene(scene);
stage.show();