diff --git a/bundles/org.openhab.binding.kodi/pom.xml b/bundles/org.openhab.binding.kodi/pom.xml index c9e7d9fff6d85..8775aab30ea90 100644 --- a/bundles/org.openhab.binding.kodi/pom.xml +++ b/bundles/org.openhab.binding.kodi/pom.xml @@ -1,4 +1,6 @@ - + + 4.0.0 diff --git a/bundles/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/protocol/KodiClientSocket.java b/bundles/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/protocol/KodiClientSocket.java index 3b6c5dc4f04da..757e0dfa500e8 100644 --- a/bundles/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/protocol/KodiClientSocket.java +++ b/bundles/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/internal/protocol/KodiClientSocket.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.net.URI; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -58,6 +59,7 @@ public class KodiClientSocket { private final URI uri; private final WebSocketClient client; private Session session; + private Future sessionFuture; private final KodiClientSocketEventListener eventHandler; @@ -81,7 +83,7 @@ public synchronized void open() throws IOException { KodiWebSocketListener socket = new KodiWebSocketListener(); ClientUpgradeRequest request = new ClientUpgradeRequest(); - client.connect(socket, uri, request); + sessionFuture = client.connect(socket, uri, request); } /*** @@ -93,6 +95,10 @@ public void close() { session.close(); session = null; } + + if (sessionFuture != null && !sessionFuture.isDone()) { + sessionFuture.cancel(true); + } } public boolean isConnected() {