It works !
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
package client;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.layout.Border;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Stage;
|
||||
import network.protocol.packets.ServerResponsePacket;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,30 +17,44 @@ public class ClientGuiController implements ClientListener {
|
||||
|
||||
private Client client;
|
||||
|
||||
@FXML
|
||||
private BorderPane vueContainer;
|
||||
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
@FXML
|
||||
public void initialize() throws SocketException {
|
||||
client = new Client(new InetSocketAddress("localhost", 6665), this, UsernameSingleton.getInstance().getUsername());
|
||||
Platform.runLater(() -> {
|
||||
Stage stage = (Stage) vueContainer.getScene().getWindow();
|
||||
stage.setOnCloseRequest(event -> {
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDisconnect() {
|
||||
|
||||
System.out.println("Disconnected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleConnexionError() {
|
||||
|
||||
System.out.println("Connection error");
|
||||
System.out.println(UsernameSingleton.getInstance().getUsername());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleConnect() {
|
||||
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Connection");
|
||||
alert.setHeaderText("Connection to the server successful");
|
||||
alert.showAndWait();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChatMessage(Instant time, String chatter, String content) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user