class AgentServer
Swift
final class AgentServer
A local automation server: newline-delimited JSON over TCP on 127.0.0.1.
LavaApp starts one when LAVA_AGENT_PORT is set; see docs/agent.md for
the protocol. Requests are handled on the UI thread from poll(), so the
handlers may touch layout and rendering. A watcher thread only wakes the
frame loop when a socket becomes readable.
Sources/LavaUI/AgentServer.swift:143
Constructors
init?(host: AgentHost, port: UInt16, wakeMainLoop: @escaping @Sendable () -> Void)
Binds 127.0.0.1:port and starts listening.
Returns nil when port is zero or the port cannot be bound.
- host: What the requests act on.
- port: The port to listen on.
- wakeMainLoop: Called from the watcher thread when a request is waiting,
to unblock the frame loop's
pumpEvents. Must be thread-safe.
Sources/LavaUI/AgentServer.swift:165
Properties
var port: UInt16 { get }
The TCP port the server listens on.
Sources/LavaUI/AgentServer.swift:149
Methods
func close()
Stops the watcher thread and closes the listening and client sockets.
Sources/LavaUI/AgentServer.swift:189
func poll()
Non-blocking: accept clients and process complete request lines.
Call on the UI thread after pumpEvents returns.
Sources/LavaUI/AgentServer.swift:210