From c03316adede7b9b4689affdfbddb7cac72d103a6 Mon Sep 17 00:00:00 2001 From: Gianlu Date: Wed, 22 Apr 2020 15:42:52 +0200 Subject: [PATCH] Report active user even if session is not active (#210) --- .../java/xyz/gianlu/librespot/core/ZeroconfServer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/xyz/gianlu/librespot/core/ZeroconfServer.java b/core/src/main/java/xyz/gianlu/librespot/core/ZeroconfServer.java index a04c2e7c..f05717e3 100644 --- a/core/src/main/java/xyz/gianlu/librespot/core/ZeroconfServer.java +++ b/core/src/main/java/xyz/gianlu/librespot/core/ZeroconfServer.java @@ -221,8 +221,8 @@ public void closeSession() throws IOException { connectionTime = 0; } - private boolean hasActiveSession() { - boolean valid = session != null && session.isValid() && session.isActive(); + private boolean hasValidSession() { + boolean valid = session != null && session.isValid(); if (!valid) { session = null; connectionTime = 0; @@ -231,9 +231,13 @@ private boolean hasActiveSession() { return valid; } + private boolean hasActiveSession() { + return hasValidSession() && session.isActive(); + } + private void handleGetInfo(OutputStream out, String httpVersion) throws IOException { JsonObject info = DEFAULT_GET_INFO_FIELDS.deepCopy(); - info.addProperty("activeUser", hasActiveSession() ? session.username() : ""); + info.addProperty("activeUser", hasValidSession() ? session.username() : ""); info.addProperty("deviceID", inner.deviceId); info.addProperty("remoteName", inner.deviceName); info.addProperty("publicKey", Base64.getEncoder().encodeToString(keys.publicKeyArray()));