AIServer

class AIServer(port: Int = 8081) : NanoWSD

WebSocket server for AI client communication.

Provides a WebSocket interface for AI agents to execute robot actions and receive state updates. Supports request-response correlation via request IDs and provides heartbeat functionality for connection health monitoring.

Parameters

port

the port to listen on (default: 8081)

Constructors

Link copied to clipboard
constructor(port: Int = 8081)

Types

Link copied to clipboard
data class ActionResult(val success: Boolean, val message: String, val data: Map<String, Any?>? = null, val actionId: String? = null)

Result of an action execution.

Link copied to clipboard
inner class AIWebSocket(handshake: NanoHTTPD.IHTTPSession?) : NanoWSD.WebSocket
Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val hostname: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var serverSocketFactory: NanoHTTPD.ServerSocketFactory?
Link copied to clipboard
open var tempFileManagerFactory: NanoHTTPD.TempFileManagerFactory?

Functions

Link copied to clipboard
fun broadcastActionComplete(actionId: String, requestId: String?, success: Boolean, message: String, data: Map<String, Any?>? = null)

Broadcasts an action completion notification to the connected client.

Link copied to clipboard

Broadcasts the current robot state to the connected client.

Link copied to clipboard
Link copied to clipboard

Returns whether there is an active, healthy client connection.

Link copied to clipboard
open fun makeSecure(sslServerSocketFactory: SSLServerSocketFactory?, sslProtocols: Array<out String?>?)
Link copied to clipboard
fun sendPing()

Sends a ping to the active client to check connection health.

Link copied to clipboard
open fun serve(session: NanoHTTPD.IHTTPSession?): NanoHTTPD.Response?
open fun serve(uri: String?, method: NanoHTTPD.Method?, headers: Map<String?, String?>?, parms: Map<String?, String?>?, files: Map<String?, String?>?): NanoHTTPD.Response?
Link copied to clipboard

Sets the callback for handling action execution requests.

Link copied to clipboard
open fun setAsyncRunner(asyncRunner: NanoHTTPD.AsyncRunner?)
Link copied to clipboard
fun setStateProvider(provider: () -> Map<String, Any>)

Sets the provider for robot state data.

Link copied to clipboard
open fun start()
open fun start(timeout: Int)
open fun start(timeout: Int, daemon: Boolean)
Link copied to clipboard
open fun stop()
Link copied to clipboard