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