diff --git a/pom.xml b/pom.xml index ff0ea2f..eb36ba1 100644 --- a/pom.xml +++ b/pom.xml @@ -60,12 +60,6 @@ src src/test/ - - - resources - - - org.apache.maven.plugins diff --git a/src/fr/univ/lyon1/client/Client.java b/src/fr/univ/lyon1/client/Client.java index ec650a1..36b4b73 100644 --- a/src/fr/univ/lyon1/client/Client.java +++ b/src/fr/univ/lyon1/client/Client.java @@ -31,7 +31,7 @@ public class Client { protected boolean started = false; - public Client(String address, int port, String username, String password) throws Exception { + public Client(String address, int port, String username, String password) throws IOException { this.address = address; this.port = port; this.username = username; diff --git a/src/fr/univ/lyon1/gui/ClientGUI.java b/src/fr/univ/lyon1/gui/ClientGUI.java index 9ebaabb..a41ef37 100644 --- a/src/fr/univ/lyon1/gui/ClientGUI.java +++ b/src/fr/univ/lyon1/gui/ClientGUI.java @@ -3,15 +3,17 @@ package fr.univ.lyon1.gui; import fr.univ.lyon1.client.Client; import fr.univ.lyon1.client.ClientReceive; import fr.univ.lyon1.common.Message; +import fr.univ.lyon1.common.command.CommandType; import fr.univ.lyon1.gui.handlers.MainHandler; import fr.univ.lyon1.common.command.Command; import java.io.IOException; +import java.util.List; public class ClientGUI extends Client { private final MainHandler gui; - public ClientGUI(MainHandler handler, String address, int port) throws Exception { + public ClientGUI(MainHandler handler, String address, int port) throws IOException { super(address, port, null, null); this.gui = handler; } @@ -22,13 +24,16 @@ public class ClientGUI extends Client { } @Override - public void run() { + public void run() throws IOException { if (started) return; Thread clientReceiveThread = new Thread(new ClientReceive(this, super.socket)); clientReceiveThread.start(); + out.writeObject(new Command(CommandType.login, List.of("test", "test"))); // ToDo: Setup login + out.flush(); + started = true; } } diff --git a/src/fr/univ/lyon1/gui/MainGui.java b/src/fr/univ/lyon1/gui/MainGui.java index 4db7857..36281f9 100644 --- a/src/fr/univ/lyon1/gui/MainGui.java +++ b/src/fr/univ/lyon1/gui/MainGui.java @@ -13,7 +13,7 @@ public class MainGui extends Application { public void start(Stage stage) { try { new MainHandler().launch(stage); - } catch (IOException | InterruptedException e) { + } catch (IOException e) { // Launch server configuration try { new ServerConfigurationHandler().launch(stage); diff --git a/src/fr/univ/lyon1/gui/controller/ConnectGuiController.java b/src/fr/univ/lyon1/gui/controller/ConnectGuiController.java index 153bdab..2016191 100644 --- a/src/fr/univ/lyon1/gui/controller/ConnectGuiController.java +++ b/src/fr/univ/lyon1/gui/controller/ConnectGuiController.java @@ -54,8 +54,6 @@ public class ConnectGuiController { Dialog.showErrorDialog("Erreur", "Impossible de sauvegarder les informations de connexion au serveur"); this.connectButton.setDisable(false); System.out.println("Failed to save file, error: " + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); } } else { System.out.println("Connection not available"); diff --git a/src/fr/univ/lyon1/gui/handlers/Handler.java b/src/fr/univ/lyon1/gui/handlers/Handler.java index a2fd0b5..b339ccc 100644 --- a/src/fr/univ/lyon1/gui/handlers/Handler.java +++ b/src/fr/univ/lyon1/gui/handlers/Handler.java @@ -5,5 +5,5 @@ import javafx.stage.Stage; import java.io.IOException; public interface Handler { - void launch(Stage stage) throws IOException, InterruptedException; + void launch(Stage stage) throws IOException; } diff --git a/src/fr/univ/lyon1/gui/handlers/MainHandler.java b/src/fr/univ/lyon1/gui/handlers/MainHandler.java index 761f65b..be9a06f 100644 --- a/src/fr/univ/lyon1/gui/handlers/MainHandler.java +++ b/src/fr/univ/lyon1/gui/handlers/MainHandler.java @@ -17,7 +17,7 @@ public class MainHandler implements Handler { private ClientGUI client; @Override - public void launch(Stage stage) throws IOException, InterruptedException { + public void launch(Stage stage) throws IOException { @NotNull final ServerConfiguration serverConfiguration = ServerConfiguration.load(); this.client = new ClientGUI(this, serverConfiguration.getAddress(), serverConfiguration.getPort()); diff --git a/resources/connect_gui.fxml b/src/main/resources/connect_gui.fxml similarity index 100% rename from resources/connect_gui.fxml rename to src/main/resources/connect_gui.fxml