Skip to content
Snippets Groups Projects
Commit 12c230af authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

#174 - Reconnect to disconnected servers on icon click

parent 7d0971a0
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,8 @@ public class WebApiRemoteConnectionStateListener implements MainWindowListener {
connectionStateIcon = new FontIcon(FontAwesomeType.CLOUD);
connectionStateIcon.setSize(20);
connectionStateIcon.setOnMouseClicked(this::onIconClicked);
connectedProperty = new SimpleIntegerProperty(0);
connectedProperty.addListener((observable, oldValue, newValue) -> {
Platform.runLater(() -> {
......@@ -70,6 +72,19 @@ public class WebApiRemoteConnectionStateListener implements MainWindowListener {
);
}
private void onIconClicked(MouseEvent event) {
WebApiPlugin$.MODULE$.connections().values().stream()
.filter(client -> client.getPlayPadConnectionState() != WebSocketState.OPEN)
.forEach(client -> Worker.runLater(() -> {
try {
client.disconnect();
client.connect(1);
} catch (IOException | WebSocketException e) {
Logger.error(e);
}
}));
}
@Override
public void onInit(IMainViewController mainViewController) {
mainViewController.performLayoutDependedAction((oldToolbar, newToolbar) -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment