chatgui-android: auto_sockets=android — сокеты из конфига, лёгкое обновление без полного рестарта
- auto_sockets три-режимный: off/system/android; android берёт сокеты из [server] конфига - auto_socket_reload_config: reconcile сокетов (remove→create) по имени+addr:port, сохранение портов - etcp_create_server_socket вынесен из init_sockets; stcp_server_list_find_by_sock - instance_lite_update_sockets + JNI nativeUpdateSockets + NativeLib.updateSockets - NetworkChangeMonitor: updateSockets вместо restart; порты сохраняются при смене сети
This commit is contained in:
1 parent
c474c37284
commit
5b31a765c2
15 files changed
+266
-46
No files matched your search
@@ -333,6 +333,7 @@ class ConfigProvider(private val context: Context) {
|
||||
appendLine("db_path=$dbDir")
|
||||
appendLine("db_sync_enabled=1")
|
||||
appendLine("chatserver_enabled=1")
|
||||
appendLine("auto_sockets=android")
|
||||
appendLine()
|
||||
for (srv in servers) appendServerSection(this, srv, false)
|
||||
for (srv in commented) appendServerSection(this, srv, true)
|
||||
|
||||
@@ -44,6 +44,11 @@ object NativeLib {
|
||||
return nativeRestart(configText)
|
||||
}
|
||||
|
||||
/** Лёгкое обновление сокетов (auto_sockets=android) без полного рестарта ядра */
|
||||
fun updateSockets(configText: String): Boolean {
|
||||
return nativeUpdateSockets(configText)
|
||||
}
|
||||
|
||||
fun isReady(): Boolean = nativeIsRunning()
|
||||
|
||||
fun getMyNodeId(): Long = nativeGetMyNodeId()
|
||||
@@ -156,6 +161,7 @@ object NativeLib {
|
||||
private external fun nativeRequestInviteCandidates(channelId: String)
|
||||
private external fun nativeRequestInviteLink(channelId: String, targetNodeId: Long)
|
||||
private external fun nativeRestart(configText: String): Boolean
|
||||
private external fun nativeUpdateSockets(configText: String): Boolean
|
||||
private external fun nativePing()
|
||||
private external fun nativeIsResponsive(): Boolean
|
||||
private external fun nativeIsRunning(): Boolean
|
||||
|
||||
@@ -69,9 +69,7 @@ object NetworkChangeMonitor {
|
||||
val nowStr = now.joinToString(", ") { (n, ip) -> "$n=$ip" }
|
||||
LogManager.addLog("INFO", "NET", "network change: [$prevStr] -> [$nowStr]")
|
||||
NativeLib.notifyNetworkActive()
|
||||
val path = provider.getString("db.path") ?: ""
|
||||
val port = provider.getInt("control.port")
|
||||
NativeLib.restart(path, port, provider.buildConfigText())
|
||||
NativeLib.updateSockets(provider.buildConfigText())
|
||||
} finally {
|
||||
restarting = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user