Fix stupid bug
This commit is contained in:
parent
7cf3b41e6a
commit
931e34bcaa
6 changed files with 26 additions and 6 deletions
|
@ -30,22 +30,23 @@ public class Client {
|
||||||
private List<Channel> channels = new ArrayList<>();
|
private List<Channel> channels = new ArrayList<>();
|
||||||
protected boolean started = false;
|
protected boolean started = false;
|
||||||
|
|
||||||
|
|
||||||
public Client(String address, int port, String username, String password) throws IOException {
|
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;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
System.out.println("Init SSL...");
|
||||||
socket = initSSL();
|
socket = initSSL();
|
||||||
|
System.out.println("Set output stream...");
|
||||||
out = new ObjectOutputStream(socket.getOutputStream());
|
out = new ObjectOutputStream(socket.getOutputStream());
|
||||||
|
System.out.println("Get In...");
|
||||||
getIn();
|
getIn();
|
||||||
|
System.out.println("Client ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Socket initSSL() throws IOException {
|
private Socket initSSL() throws IOException {
|
||||||
SSLContext ctx = ChatSSL.getSSLContext();
|
SSLContext ctx = ChatSSL.getSSLContext();
|
||||||
|
|
||||||
SocketFactory factory = ctx.getSocketFactory();
|
SocketFactory factory = ctx.getSocketFactory();
|
||||||
|
|
||||||
Socket connection = factory.createSocket(address, port);
|
Socket connection = factory.createSocket(address, port);
|
||||||
((SSLSocket) connection).setEnabledProtocols(new String[] {ChatSSL.tlsVersion});
|
((SSLSocket) connection).setEnabledProtocols(new String[] {ChatSSL.tlsVersion});
|
||||||
SSLParameters sslParams = new SSLParameters();
|
SSLParameters sslParams = new SSLParameters();
|
||||||
|
|
|
@ -14,6 +14,8 @@ public class MainGui extends Application {
|
||||||
try {
|
try {
|
||||||
new MainHandler().launch(stage);
|
new MainHandler().launch(stage);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
// Launch server configuration
|
// Launch server configuration
|
||||||
try {
|
try {
|
||||||
new ServerConfigurationHandler().launch(stage);
|
new ServerConfigurationHandler().launch(stage);
|
||||||
|
|
|
@ -44,13 +44,17 @@ public class ConnectGuiController {
|
||||||
try {
|
try {
|
||||||
// Save server configuration
|
// Save server configuration
|
||||||
new ServerConfiguration(address, iPort).save();
|
new ServerConfiguration(address, iPort).save();
|
||||||
Dialog.showSuccessDialog("Connecté", "Vous êtes bien connecté au serveur");
|
// Dialog.showSuccessDialog("Connecté", "Vous êtes bien connecté au serveur");
|
||||||
System.out.println("File saved, next step...");
|
System.out.println("File saved, next step...");
|
||||||
|
|
||||||
|
System.out.println("Get scene...");
|
||||||
@NotNull
|
@NotNull
|
||||||
final Stage stage = (Stage) this.connectButton.getScene().getWindow();
|
final Stage stage = (Stage) this.connectButton.getScene().getWindow();
|
||||||
|
System.out.println("Scene : " + stage.toString());
|
||||||
new MainHandler().launch(stage);
|
new MainHandler().launch(stage);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
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());
|
||||||
|
@ -84,8 +88,10 @@ public class ConnectGuiController {
|
||||||
@NotNull
|
@NotNull
|
||||||
final Socket socket = new Socket(address, port);
|
final Socket socket = new Socket(address, port);
|
||||||
socket.setSoTimeout(5 * 1000);
|
socket.setSoTimeout(5 * 1000);
|
||||||
|
boolean connected = socket.isConnected();
|
||||||
|
socket.close();
|
||||||
|
|
||||||
return true;
|
return connected;
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,19 @@ public class Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showSuccessDialog(String title, String description) {
|
public static void showSuccessDialog(String title, String description) {
|
||||||
|
System.out.println("Create success dialog...");
|
||||||
@NotNull
|
@NotNull
|
||||||
final Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
final Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
|
System.out.println("Extracting...");
|
||||||
extracted(title, description, alert);
|
extracted(title, description, alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void extracted(String title, String description, @NotNull Alert alert) {
|
private static void extracted(String title, String description, @NotNull Alert alert) {
|
||||||
|
System.out.println("Set title");
|
||||||
alert.setTitle(title);
|
alert.setTitle(title);
|
||||||
|
System.out.println("Set description");
|
||||||
alert.setContentText(description);
|
alert.setContentText(description);
|
||||||
|
System.out.println("Show");
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,22 +18,28 @@ public class MainHandler implements Handler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launch(Stage stage) throws IOException {
|
public void launch(Stage stage) throws IOException {
|
||||||
|
System.out.println("New...");
|
||||||
@NotNull
|
@NotNull
|
||||||
final ServerConfiguration serverConfiguration = ServerConfiguration.load();
|
final ServerConfiguration serverConfiguration = ServerConfiguration.load();
|
||||||
|
System.out.println("Launch Client GUI...");
|
||||||
this.client = new ClientGUI(this, serverConfiguration.getAddress(), serverConfiguration.getPort());
|
this.client = new ClientGUI(this, serverConfiguration.getAddress(), serverConfiguration.getPort());
|
||||||
|
|
||||||
|
System.out.println("Set...");
|
||||||
stage.setTitle("Chat client");
|
stage.setTitle("Chat client");
|
||||||
stage.setWidth(440);
|
stage.setWidth(440);
|
||||||
|
|
||||||
|
System.out.println("Set panel...");
|
||||||
this.clientPanel = new ClientPanel(this);
|
this.clientPanel = new ClientPanel(this);
|
||||||
Group root = new Group();
|
Group root = new Group();
|
||||||
root.getChildren().add(this.clientPanel);
|
root.getChildren().add(this.clientPanel);
|
||||||
Scene scene = new Scene(root, 600, 500);
|
Scene scene = new Scene(root, 600, 500);
|
||||||
|
|
||||||
|
System.out.println("Set scene...");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
if (this.client != null) {
|
if (this.client != null) {
|
||||||
|
System.out.println("Run...");
|
||||||
this.client.run();
|
this.client.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module fr.univ.lyon {
|
module fr.univ.lyon1 {
|
||||||
requires javafx.controls;
|
requires javafx.controls;
|
||||||
requires javafx.fxml;
|
requires javafx.fxml;
|
||||||
|
|
||||||
|
|
Reference in a new issue