Commit 65fd2fb5 authored by Lisa (AI Assistant)'s avatar Lisa (AI Assistant)

Fix: Add stored config variables for retry logic

parent 9b310d25
......@@ -40,6 +40,13 @@ class NodeService : Service() {
private val screenshotService by lazy { ScreenshotService(this) }
// Store config for retry logic
private var storedIp = ""
private var storedPort = "18789"
private var storedToken = ""
private var storedProtocol = "WS"
private var storedNodeId = ""
override fun onBind(intent: Intent?): IBinder? = null
override fun onCreate() {
......@@ -81,6 +88,13 @@ class NodeService : Service() {
}
// END TEMPORARY CONFIG
// Store for retry logic
storedIp = ip
storedPort = port
storedToken = token
storedProtocol = protocol
storedNodeId = nodeId
Log.e(TAG, "Settings read: ip=$ip tokenLen=${token.length} port=$port")
if (ip.isNotBlank() && token.isNotBlank()) {
......@@ -204,10 +218,10 @@ class NodeService : Service() {
Log.e(TAG, "Connection failed, scheduling retry in 3 seconds...")
scope.launch {
delay(3000)
if (ip.isNotBlank() && token.isNotBlank()) {
val fullUrl = if (protocol == "WSS") "wss://$ip:$port" else "ws://$ip:$port"
if (storedIp.isNotBlank() && storedToken.isNotBlank()) {
val fullUrl = if (storedProtocol == "WSS") "wss://${storedIp}:${storedPort}" else "ws://${storedIp}:${storedPort}"
Log.e(TAG, "Retrying connection to: $fullUrl")
startNode(fullUrl, token, nodeId)
startNode(fullUrl, storedToken, storedNodeId)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment