Merge flifloo into main
This commit is contained in:
parent
57501b7b93
commit
371a1bb0cb
8 changed files with 11 additions and 14 deletions
6
pom.xml
6
pom.xml
|
@ -60,12 +60,6 @@
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<testSourceDirectory>src/test/</testSourceDirectory>
|
<testSourceDirectory>src/test/</testSourceDirectory>
|
||||||
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<targetPath>resources</targetPath>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Client {
|
||||||
protected boolean started = false;
|
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.address = address;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
|
|
@ -3,15 +3,17 @@ package fr.univ.lyon1.gui;
|
||||||
import fr.univ.lyon1.client.Client;
|
import fr.univ.lyon1.client.Client;
|
||||||
import fr.univ.lyon1.client.ClientReceive;
|
import fr.univ.lyon1.client.ClientReceive;
|
||||||
import fr.univ.lyon1.common.Message;
|
import fr.univ.lyon1.common.Message;
|
||||||
|
import fr.univ.lyon1.common.command.CommandType;
|
||||||
import fr.univ.lyon1.gui.handlers.MainHandler;
|
import fr.univ.lyon1.gui.handlers.MainHandler;
|
||||||
import fr.univ.lyon1.common.command.Command;
|
import fr.univ.lyon1.common.command.Command;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ClientGUI extends Client {
|
public class ClientGUI extends Client {
|
||||||
private final MainHandler gui;
|
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);
|
super(address, port, null, null);
|
||||||
this.gui = handler;
|
this.gui = handler;
|
||||||
}
|
}
|
||||||
|
@ -22,13 +24,16 @@ public class ClientGUI extends Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() throws IOException {
|
||||||
if (started)
|
if (started)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Thread clientReceiveThread = new Thread(new ClientReceive(this, super.socket));
|
Thread clientReceiveThread = new Thread(new ClientReceive(this, super.socket));
|
||||||
clientReceiveThread.start();
|
clientReceiveThread.start();
|
||||||
|
|
||||||
|
out.writeObject(new Command(CommandType.login, List.of("test", "test"))); // ToDo: Setup login
|
||||||
|
out.flush();
|
||||||
|
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class MainGui extends Application {
|
||||||
public void start(Stage stage) {
|
public void start(Stage stage) {
|
||||||
try {
|
try {
|
||||||
new MainHandler().launch(stage);
|
new MainHandler().launch(stage);
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException e) {
|
||||||
// Launch server configuration
|
// Launch server configuration
|
||||||
try {
|
try {
|
||||||
new ServerConfigurationHandler().launch(stage);
|
new ServerConfigurationHandler().launch(stage);
|
||||||
|
|
|
@ -54,8 +54,6 @@ public class ConnectGuiController {
|
||||||
Dialog.showErrorDialog("Erreur", "Impossible de sauvegarder les informations de connexion au serveur");
|
Dialog.showErrorDialog("Erreur", "Impossible de sauvegarder les informations de connexion au serveur");
|
||||||
this.connectButton.setDisable(false);
|
this.connectButton.setDisable(false);
|
||||||
System.out.println("Failed to save file, error: " + e.getMessage());
|
System.out.println("Failed to save file, error: " + e.getMessage());
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Connection not available");
|
System.out.println("Connection not available");
|
||||||
|
|
|
@ -5,5 +5,5 @@ import javafx.stage.Stage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public interface Handler {
|
public interface Handler {
|
||||||
void launch(Stage stage) throws IOException, InterruptedException;
|
void launch(Stage stage) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class MainHandler implements Handler {
|
||||||
private ClientGUI client;
|
private ClientGUI client;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launch(Stage stage) throws IOException, InterruptedException {
|
public void launch(Stage stage) throws IOException {
|
||||||
@NotNull
|
@NotNull
|
||||||
final ServerConfiguration serverConfiguration = ServerConfiguration.load();
|
final ServerConfiguration serverConfiguration = ServerConfiguration.load();
|
||||||
this.client = new ClientGUI(this, serverConfiguration.getAddress(), serverConfiguration.getPort());
|
this.client = new ClientGUI(this, serverConfiguration.getAddress(), serverConfiguration.getPort());
|
||||||
|
|
Reference in a new issue