diff seobeo/seobeo_internal.h @ 257:609d3c6aff4e

[seobeo] Add persistent SSE streams Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Tue, 04 Aug 2026 16:49:11 -0700
parents ce7f4400c2de
children 1f9877b637e9
line wrap: on
line diff
--- a/seobeo/seobeo_internal.h	Tue Aug 04 16:49:01 2026 -0700
+++ b/seobeo/seobeo_internal.h	Tue Aug 04 16:49:11 2026 -0700
@@ -52,6 +52,7 @@
   // Keep-alive support
   time_t      last_activity;  // Timestamp of last request/response
   boolean     keep_alive;     // Whether this connection should be kept alive
+  boolean     is_sse;         // SSE takeover; edge loop only watches disconnects
 } Seobeo_Handle;
 
 // Cached file entry with content and size (for binary file support)
@@ -77,6 +78,24 @@
 // HTTP request map type: maps header names to header values
 typedef Dowa_KV(char*, char*) Seobeo_Request_Entry;
 
+typedef struct {
+  Seobeo_Handle *p_handle;
+  char *path;
+  void *p_pending_frames;
+  size_t pending_offset;
+  atomic_uint ref_count;
+  boolean started;
+  boolean closed;
+  boolean managed;
+} Seobeo_SSE_Stream;
+
+typedef struct {
+  const char *event;
+  const char *id;
+  const char *data;
+  int32 retry_ms;
+} Seobeo_SSE_Event;
+
 // --- Router Types --- //
 // Forward declaration
 typedef struct Seobeo_Route_Struct Seobeo_Route;
@@ -94,6 +113,18 @@
     Dowa_Arena *p_arena
 );
 
+typedef void (*Seobeo_SSE_Handler)(
+    Seobeo_SSE_Stream *p_stream,
+    Seobeo_Request_Entry *p_request_map,
+    Dowa_Arena *p_arena
+);
+
+extern Seobeo_SSE_Stream *Seobeo_SSE_Server_Attach(
+    Seobeo_Handle *p_handle,
+    const char *path);
+extern void Seobeo_SSE_Server_Detach_Handle(Seobeo_Handle *p_handle);
+extern void Seobeo_SSE_Server_Destroy(void);
+
 // --- Parse Header into Dowa Map ---//
 extern int            Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Seobeo_Request_Entry **pp_map, Dowa_Arena *p_arena);