Skip to content

Commit 2745b50

Browse files
committed
Fixed /discovery/list failing with multiple clients on the network (#352)
1 parent c9f9f53 commit 2745b50

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

api/src/main/java/xyz/gianlu/librespot/api/handlers/DiscoveryHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
*/
3838
public final class DiscoveryHandler implements HttpHandler {
3939
private static final Logger LOGGER = LoggerFactory.getLogger(DiscoveryHandler.class);
40-
private final Zeroconf zeroconf;
40+
private final Zeroconf.DiscoveredServices discoverer;
4141

4242
public DiscoveryHandler() {
43-
zeroconf = new Zeroconf()
43+
Zeroconf zeroconf = new Zeroconf()
4444
.setUseIpv4(true)
4545
.setUseIpv6(false);
4646

@@ -49,6 +49,8 @@ public DiscoveryHandler() {
4949
} catch (IOException ex) {
5050
LOGGER.error("Failed adding network interfaces for Zeroconf.", ex);
5151
}
52+
53+
discoverer = zeroconf.discover(ZeroconfServer.SERVICE, "tcp", ".local");
5254
}
5355

5456
@Override
@@ -69,7 +71,7 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
6971
switch (action) {
7072
case "list":
7173
JsonArray array = new JsonArray();
72-
for (DiscoveredService service : zeroconf.discover(ZeroconfServer.SERVICE, "tcp", ".local")) {
74+
for (DiscoveredService service : discoverer.getServices()) {
7375
JsonObject obj = new JsonObject();
7476
obj.addProperty("name", service.name);
7577
obj.addProperty("target", service.target);

lib/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<dependency>
117117
<groupId>xyz.gianlu.zeroconf</groupId>
118118
<artifactId>zeroconf</artifactId>
119-
<version>1.2.2</version>
119+
<version>1.3.0</version>
120120
</dependency>
121121

122122
<!-- HTTP -->

0 commit comments

Comments
 (0)