Исправление бесконечного рендер-цикла SearchView и поиск по публичному ключу
This commit is contained in:
@@ -328,14 +328,13 @@ final class ProtocolManager: @unchecked Sendable {
|
||||
|
||||
private func startHeartbeat(interval: Int) {
|
||||
heartbeatTask?.cancel()
|
||||
let intervalMs = UInt64(interval) * 1_000_000_000 / 3
|
||||
// Match Android: intervalMs = (intervalSeconds * 1000L) / 2
|
||||
let intervalNs = UInt64(interval) * 1_000_000_000 / 2
|
||||
|
||||
heartbeatTask = Task {
|
||||
// Send first heartbeat immediately
|
||||
client.sendText("heartbeat")
|
||||
|
||||
// Match Android: delay first, then send (no immediate first beat)
|
||||
while !Task.isCancelled {
|
||||
try? await Task.sleep(nanoseconds: intervalMs)
|
||||
try? await Task.sleep(nanoseconds: intervalNs)
|
||||
guard !Task.isCancelled else { break }
|
||||
client.sendText("heartbeat")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user