Mercurial
diff seobeo/examples/sse_server_example.c @ 260:1f9877b637e9
Add Copilot-powered cyberpunk JRPG chat
Integrate the production JRPG chat with Seobeo streaming, Deita persistence, and a Bazel-managed Copilot SDK and LiteLLM inference stack.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <mrjunejune@users.noreply.github.com> |
|---|---|
| date | Wed, 05 Aug 2026 09:19:41 -0700 |
| parents | 609d3c6aff4e |
| children |
line wrap: on
line diff
--- a/seobeo/examples/sse_server_example.c Wed Aug 05 09:19:41 2026 -0700 +++ b/seobeo/examples/sse_server_example.c Wed Aug 05 09:19:41 2026 -0700 @@ -1,5 +1,6 @@ #include "seobeo/seobeo.h" +#include <stdio.h> #include <unistd.h> static void Send_Later(void *p_context) @@ -34,6 +35,27 @@ } } +static void Post_Events( + Seobeo_SSE_Stream *p_stream, + Seobeo_Request_Entry *p_request, + Dowa_Arena *p_arena) +{ + (void)p_arena; + Seobeo_Request_Entry *p_topic = + Dowa_HashMap_Get_Ptr(p_request, ":topic"); + Seobeo_Request_Entry *p_body = + Dowa_HashMap_Get_Ptr(p_request, "Body"); + char event[256]; + int length = snprintf( + event, + sizeof(event), + "topic=%s body=%s", + p_topic ? p_topic->value : "", + p_body ? p_body->value : ""); + if (length > 0 && (size_t)length < sizeof(event)) + Seobeo_SSE_Send_Data(p_stream, event); +} + static Seobeo_Request_Entry *Health( Seobeo_Request_Entry *p_request, Dowa_Arena *p_arena) @@ -55,6 +77,10 @@ const char *port = argc > 1 ? argv[1] : "18081"; Seobeo_Router_Init(); Seobeo_Router_Register_SSE("/events", Events); + Seobeo_Router_Register_SSE_Method( + "POST", + "/events/:topic", + Post_Events); Seobeo_Router_Register("GET", "/health", Health); int result = Seobeo_Web_Server_Start_On( "127.0.0.1",