add disconnect to server

This commit is contained in:
Mateusz Kowalczyk 2020-01-04 21:54:38 +01:00
parent f3a6059f05
commit 92e40247f9
3 changed files with 16 additions and 0 deletions

View File

@ -48,6 +48,7 @@ public class ServerPanelController implements Initializable {
@FXML
public void closeConnection(Event e) {
this.server.closeConnection();
this.mainPageController.serverContainer.getChildren().remove(this.serverPane);
}

View File

@ -76,4 +76,15 @@ public class Server {
public void setServerPanel(ServerPanelController serverPanelController) {
this.serverPanelController = serverPanelController;
}
public void closeConnection() {
try {
this.getConnector().disconnect();
this.socket.close();
} catch (CannotConnectException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -146,4 +146,8 @@ public class ServerConnector {
e.printStackTrace();
}
}
public void disconnect() throws CannotConnectException {
this.sendRequest("DISCONNECT");
}
}