add disconnect to server
This commit is contained in:
parent
f3a6059f05
commit
92e40247f9
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,4 +146,8 @@ public class ServerConnector {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() throws CannotConnectException {
|
||||
this.sendRequest("DISCONNECT");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user