diff --git a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/java/de/tobias/playpad/plugin/api/client/WebApiRemoteConnectionStateListener.java b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/java/de/tobias/playpad/plugin/api/client/WebApiRemoteConnectionStateListener.java index 5611562f1f5b73808da72a4d00a536002549e408..0b1d2b8c5ee2bdf2b546517ce94ad5ab47d2e6ad 100644 --- a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/java/de/tobias/playpad/plugin/api/client/WebApiRemoteConnectionStateListener.java +++ b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/java/de/tobias/playpad/plugin/api/client/WebApiRemoteConnectionStateListener.java @@ -1,13 +1,13 @@ package de.tobias.playpad.plugin.api.client; import com.neovisionaries.ws.client.WebSocketException; -import com.neovisionaries.ws.client.WebSocketState; import de.thecodelabs.logger.Logger; import de.thecodelabs.utils.threading.Worker; import de.thecodelabs.utils.ui.icon.FontAwesomeType; import de.thecodelabs.utils.ui.icon.FontIcon; import de.thecodelabs.utils.util.Localization; import de.tobias.playpad.api.PlayPadClient; +import de.tobias.playpad.api.PlayPadConnectionState; import de.tobias.playpad.plugin.MainWindowListener; import de.tobias.playpad.plugin.api.WebApiPlugin$; import de.tobias.playpad.viewcontroller.main.IMainViewController; @@ -43,7 +43,7 @@ public class WebApiRemoteConnectionStateListener implements MainWindowListener { connectionStateIcon.setIcons(allConnected ? FontAwesomeType.CLOUD : FontAwesomeType.EXCLAMATION_CIRCLE); if (!allConnected) { final String disconnectedServers = WebApiPlugin$.MODULE$.connections().entrySet().stream() - .filter(entry -> entry.getValue().getPlayPadConnectionState() != WebSocketState.OPEN) + .filter(entry -> entry.getValue().getPlayPadConnectionState() != PlayPadConnectionState.CONNECTED) .map(entry -> entry.getKey().getName()).collect(Collectors.joining(", ")); connectionStateIcon.setTooltip(new Tooltip(Localization.getString("webapi-settings.remote.state.tooltip", disconnectedServers))); connectionStateIcon.setStyle("-fx-text-fill: red;"); @@ -65,7 +65,7 @@ public class WebApiRemoteConnectionStateListener implements MainWindowListener { private void createConnectionStateBinding() { final List<PlayPadClient> clients = new ArrayList<>(WebApiPlugin$.MODULE$.connections().values()); connectedProperty.bind(Bindings.createIntegerBinding(() -> (int) WebApiPlugin$.MODULE$.connections().values().stream() - .filter(client -> client.getPlayPadConnectionState() != WebSocketState.OPEN) + .filter(client -> client.getPlayPadConnectionState() != PlayPadConnectionState.CONNECTED) .count(), clients.stream() .map(PlayPadClient::playPadConnectionState) @@ -75,7 +75,7 @@ public class WebApiRemoteConnectionStateListener implements MainWindowListener { private void onIconClicked(MouseEvent event) { WebApiPlugin$.MODULE$.connections().values().stream() - .filter(client -> client.getPlayPadConnectionState() != WebSocketState.OPEN) + .filter(client -> client.getPlayPadConnectionState() != PlayPadConnectionState.CONNECTED) .forEach(client -> Worker.runLater(() -> { try { client.disconnect(); diff --git a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala index 3a186c37bce988f292f7cd979f8086c4a2393b59..376d97dee8a7393a12023ede7b9d23e0e45fdfde 100644 --- a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala +++ b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala @@ -95,6 +95,7 @@ object WebApiPlugin { try { val client = new PlayPadClientImpl(f"ws://${remote.getServerAddress}:${remote.getPort}/api") WebApiPlugin.connections.put(remote, client) + client.playPadConnectionState.addListener((_, _, newValue) => println(f"State: ${remote.getName} \t $newValue")) client.connect(5) Logger.info(s"Connected to remote PlayWall: ${remote.getName}") } catch { diff --git a/pom.xml b/pom.xml index b4ae690d096eafb05f801e80971ea4b1679d740b..4e735ed3fdaf7d8165254248ab14d39fffd7fba2 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ <jackson-dataformat-csv.version>2.11.3</jackson-dataformat-csv.version> <spark-core.version>[2.9.3,)</spark-core.version> - <PlayWallWebApiClient.version>1.2.1</PlayWallWebApiClient.version> + <PlayWallWebApiClient.version>1.2.2</PlayWallWebApiClient.version> <jna.version>5.6.0</jna.version>