diff --git a/Dev_Docs/API/03_Session_Management_API.md b/Dev_Docs/API/03_Session_Management_API.md index d67e2ae..8a11287 100644 --- a/Dev_Docs/API/03_Session_Management_API.md +++ b/Dev_Docs/API/03_Session_Management_API.md @@ -44,6 +44,7 @@ "sessionId": "sess_7c5e5c4b", "sessionType": 1, "clientPlatform": "Web", + "isOnlineOnThisServer": true, "clientInfoFromClient": "Android 15; Pixel 9", "clientInfoFromRequest": "UA=Java-http-client/17.0.18; remote=127.0.0.1", "geo": "RU/Moscow", @@ -68,6 +69,7 @@ - `50` — кошелёк; - `100` — homeserver; - `clientPlatform` — строка платформы, как её прислал клиент; +- `isOnlineOnThisServer` — `true`, если эта сессия сейчас держит живое WebSocket-подключение именно к данному серверу; - `clientInfoFromClient` — краткая строка клиента; - `clientInfoFromRequest` — строка, собранная сервером из запроса; - `geo` — страна/город или fallback-строка; diff --git a/Dev_Docs/Pending_Features/2026-06-13_1540_online_flag_в_list_sessions.md b/Dev_Docs/Pending_Features/2026-06-13_1540_online_flag_в_list_sessions.md new file mode 100644 index 0000000..bb4bc88 --- /dev/null +++ b/Dev_Docs/Pending_Features/2026-06-13_1540_online_flag_в_list_sessions.md @@ -0,0 +1,16 @@ +# online flag в ListSessions + +- краткое описание: + - серверный `ListSessions` теперь возвращает флаг `isOnlineOnThisServer` для каждой сессии; + - клиентский UI показывает его и в списке устройств, и на подробной странице сеанса. + +- что проверять: + - у текущего web-клиента в списке должен быть статус `Online now`; + - у активной `ESP32`-сессии должен быть статус `Online now`, пока устройство подключено; + - после ручного закрытия одной из сессий её статус должен стать `Offline`. + +- ожидаемый результат: + - online-флаг соответствует живому наличию `WebSocket`-контекста на этом сервере, а не только данным БД. + +- статус: + - in_progress diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java index 6c47505..e53a24d 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java @@ -2,6 +2,7 @@ package server.logic.ws_protocol.JSON.handlers.auth; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import server.logic.ws_protocol.JSON.ActiveConnectionsRegistry; import server.logic.ws_protocol.JSON.ConnectionContext; import server.logic.ws_protocol.JSON.entyties.Net_Request; import server.logic.ws_protocol.JSON.entyties.Net_Response; @@ -68,6 +69,7 @@ public class Net_ListSessions_Handler implements JsonMessageHandler { info.setClientInfoFromRequest(s.getClientInfoFromRequest()); info.setSessionType(s.getSessionType()); info.setClientPlatform(s.getClientPlatform()); + info.setOnlineOnThisServer(ActiveConnectionsRegistry.getInstance().getBySessionId(s.getSessionId()) != null); info.setLastAuthenticatedAtMs(s.getLastAuthirificatedAtMs()); String ip = s.getClientIp(); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/entyties/Net_ListSessions_Response.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/entyties/Net_ListSessions_Response.java index 2bd3571..00ae36b 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/entyties/Net_ListSessions_Response.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/entyties/Net_ListSessions_Response.java @@ -58,6 +58,9 @@ public class Net_ListSessions_Response extends Net_Response { /** Свободная строка платформы, как её прислал клиент. */ private String clientPlatform; + /** Подключена ли эта сессия прямо сейчас к данному серверу. */ + private boolean onlineOnThisServer; + /** Строка геолокации вида "Country, City" или "unknown". */ private String geo; @@ -106,6 +109,14 @@ public class Net_ListSessions_Response extends Net_Response { this.clientPlatform = clientPlatform; } + public boolean isOnlineOnThisServer() { + return onlineOnThisServer; + } + + public void setOnlineOnThisServer(boolean onlineOnThisServer) { + this.onlineOnThisServer = onlineOnThisServer; + } + public String getGeo() { return geo; } diff --git a/VERSION.properties b/VERSION.properties index 26cb229..26d0b3d 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ -client.version=1.2.182 -server.version=1.2.171 +client.version=1.2.183 +server.version=1.2.172 diff --git a/shine-UI/js/pages/device-session-view.js b/shine-UI/js/pages/device-session-view.js index c8cb4df..6404560 100644 --- a/shine-UI/js/pages/device-session-view.js +++ b/shine-UI/js/pages/device-session-view.js @@ -27,6 +27,10 @@ function formatSessionTime(ms) { }); } +function formatOnlineStatus(isOnlineOnThisServer) { + return isOnlineOnThisServer ? 'Online now on this server' : 'Offline on this server'; +} + export function render({ navigate, route }) { const screen = document.createElement('section'); screen.className = 'stack'; @@ -55,6 +59,7 @@ export function render({ navigate, route }) {
${session.sessionId}
${formatSessionType(session.sessionType)}
${session.clientPlatform || '-'}
${formatOnlineStatus(!!session.isOnlineOnThisServer)}
${session.clientInfoFromClient || '-'}
${session.clientInfoFromRequest || '-'}
${session.geo || 'unknown'}