From 0f77e0c9e802bbd9bbf141e120cd1e4604c78101 Mon Sep 17 00:00:00 2001 From: SerVB Date: Tue, 15 Feb 2022 17:09:28 +0100 Subject: [PATCH] Add status endpoint --- gradle.properties | 2 +- projector-server/CHANGELOG.md | 6 ++++++ .../org/jetbrains/projector/server/ProjectorServer.kt | 10 +++++++++- .../projector/server/websocket/WebsocketServer.kt | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 98d8338c..d5f89ad0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ intellijPluginVersion=1.3.0 javassistVersion=3.28.0-GA kotlinVersion=1.6.10 mockitoKotlinVersion=4.0.0 -projectorClientVersion=aeaf9989 +projectorClientVersion=1b08e117 projectorClientGroup=com.github.JetBrains.projector-client targetJvm=11 jetbrainsMonoVersion=2.242 diff --git a/projector-server/CHANGELOG.md b/projector-server/CHANGELOG.md index 641063a8..0190f955 100644 --- a/projector-server/CHANGELOG.md +++ b/projector-server/CHANGELOG.md @@ -1,12 +1,18 @@ # Unreleased ## Fixed + - PRJ-691 PRJ-750 PRJ-779 Fix JetBrains account login - Infinite transport initialization on relay failure ## Changed + - Switch to JS IR compilation for projector-client-web +## Added + +- Status endpoint + # 1.6.0 ## Added diff --git a/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt b/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt index 86060fa2..caf08332 100644 --- a/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt +++ b/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt @@ -335,7 +335,13 @@ class ProjectorServer private constructor( return allEvents } + private var lastUserActionTimeStampMs: Long = 0L + private fun processMessage(clientSettings: ReadyClientSettings, message: ClientEvent) { + if (message is ClientUserEvent) { + lastUserActionTimeStampMs = System.currentTimeMillis() + } + if ( !clientSettings.setUpClientData.hasWriteAccess && message !is ClientRequestImageDataEvent && @@ -700,8 +706,9 @@ class ProjectorServer private constructor( fun start() { updateThread = createUpdateThread() caretInfoUpdater.start() + lastUserActionTimeStampMs = System.currentTimeMillis() - WebsocketServer.createTransportBuilders().forEach { + WebsocketServer.createTransportBuilders(getLastUserActionTimeStampMs = ::lastUserActionTimeStampMs).forEach { addTransport(it.attachDefaultServerEventHandlers(clientEventHandler).build()) } } @@ -733,6 +740,7 @@ class ProjectorServer private constructor( fun stop(timeout: Int = 0) { transports.forEach { it.stop(timeout) } transports.clear() + lastUserActionTimeStampMs = 0L caretInfoUpdater.stop() if (::updateThread.isInitialized) { diff --git a/projector-server/src/main/kotlin/org/jetbrains/projector/server/websocket/WebsocketServer.kt b/projector-server/src/main/kotlin/org/jetbrains/projector/server/websocket/WebsocketServer.kt index c27ce217..381ada50 100644 --- a/projector-server/src/main/kotlin/org/jetbrains/projector/server/websocket/WebsocketServer.kt +++ b/projector-server/src/main/kotlin/org/jetbrains/projector/server/websocket/WebsocketServer.kt @@ -35,7 +35,7 @@ import org.jetbrains.projector.server.service.ProjectorImageCacher import org.jetbrains.projector.util.logging.Logger object WebsocketServer { - internal fun createTransportBuilders(): List { + internal fun createTransportBuilders(getLastUserActionTimeStampMs: () -> Long): List { val builders = arrayListOf() val relayUrl = getOption(RELAY_PROPERTY_NAME) @@ -68,6 +68,7 @@ object WebsocketServer { ) } } + serverBuilder.getLastUserActionTimeStampMs = getLastUserActionTimeStampMs builders.add(serverBuilder) }