feat: add WebSocket gateway on port 18789
JSON protocol server using esp_http_server with WS upgrade. Supports up to 4 concurrent clients, auto-assigned chat_id, routes messages through the agent via message bus. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
25
main/gateway/ws_server.h
Normal file
25
main/gateway/ws_server.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* Initialize and start the WebSocket server on MIMI_WS_PORT.
|
||||
* Allows external clients to interact with the Agent via JSON messages.
|
||||
*
|
||||
* Protocol:
|
||||
* Inbound: {"type":"message","content":"hello","chat_id":"ws_client1"}
|
||||
* Outbound: {"type":"response","content":"Hi!","chat_id":"ws_client1"}
|
||||
*/
|
||||
esp_err_t ws_server_start(void);
|
||||
|
||||
/**
|
||||
* Send a text message to a specific WebSocket client by chat_id.
|
||||
* @param chat_id Client identifier (assigned on connection)
|
||||
* @param text Message text
|
||||
*/
|
||||
esp_err_t ws_server_send(const char *chat_id, const char *text);
|
||||
|
||||
/**
|
||||
* Stop the WebSocket server.
|
||||
*/
|
||||
esp_err_t ws_server_stop(void);
|
||||
Reference in New Issue
Block a user