Use randomized Android GUI port

This commit is contained in:
Butterscotch! committed 2025-12-07 05:20:13 -05:00
1 parent 364ed3209c
commit 066c28adb4
2 files changed
+4 -2

No files matched your search

@@ -40,7 +40,7 @@ val vrServerInitialized: Boolean
fun startWebServer() {
// Host the web GUI server
webServer = embeddedServer(Netty, port = 34536) {
webServer = embeddedServer(Netty, port = 0) {
routing {
install(CachingHeaders) {
options { _, _ ->
@@ -7,6 +7,7 @@ import android.webkit.WebSettings
import android.webkit.WebView
import androidx.appcompat.app.AppCompatActivity
import io.eiren.util.logging.LogManager
import kotlinx.coroutines.runBlocking
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
@@ -71,7 +72,8 @@ class MainActivity : AppCompatActivity() {
guiWebView.clearCache(true)
// Load GUI page
guiWebView.loadUrl("http://127.0.0.1:34536/")
val port = runBlocking { webServer.engine.resolvedConnectors().first().port }
guiWebView.loadUrl("http://127.0.0.1:$port/")
LogManager.info("[MainActivity] GUI WebView has been initialized and loaded.")
// Start a foreground service to notify the user the SlimeVR Server is running