mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
fix(computer): reap mac helper after client loss (#11425)
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
public struct AgentSessionOwnership: Sendable {
|
||||
private var authenticatedConnections: Set<Int32> = []
|
||||
private var wasClaimed = false
|
||||
|
||||
public init() {}
|
||||
|
||||
public mutating func registerConnection(_ connection: Int32, authenticated: Bool) -> Bool {
|
||||
guard authenticated else { return false }
|
||||
let inserted = authenticatedConnections.insert(connection).inserted
|
||||
guard inserted, !wasClaimed else { return false }
|
||||
wasClaimed = true
|
||||
return true
|
||||
}
|
||||
|
||||
public mutating func disconnect(_ connection: Int32) -> Bool {
|
||||
guard authenticatedConnections.remove(connection) != nil else { return false }
|
||||
return wasClaimed && authenticatedConnections.isEmpty
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user