comparison 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
comparison
equal deleted inserted replaced
256:30c2196d03d4 257:609d3c6aff4e
50 atomic_bool destroyed; 50 atomic_bool destroyed;
51 51
52 // Keep-alive support 52 // Keep-alive support
53 time_t last_activity; // Timestamp of last request/response 53 time_t last_activity; // Timestamp of last request/response
54 boolean keep_alive; // Whether this connection should be kept alive 54 boolean keep_alive; // Whether this connection should be kept alive
55 boolean is_sse; // SSE takeover; edge loop only watches disconnects
55 } Seobeo_Handle; 56 } Seobeo_Handle;
56 57
57 // Cached file entry with content and size (for binary file support) 58 // Cached file entry with content and size (for binary file support)
58 typedef struct { 59 typedef struct {
59 char *content; 60 char *content;
74 } Seobeo_ServerMode; 75 } Seobeo_ServerMode;
75 76
76 77
77 // HTTP request map type: maps header names to header values 78 // HTTP request map type: maps header names to header values
78 typedef Dowa_KV(char*, char*) Seobeo_Request_Entry; 79 typedef Dowa_KV(char*, char*) Seobeo_Request_Entry;
80
81 typedef struct {
82 Seobeo_Handle *p_handle;
83 char *path;
84 void *p_pending_frames;
85 size_t pending_offset;
86 atomic_uint ref_count;
87 boolean started;
88 boolean closed;
89 boolean managed;
90 } Seobeo_SSE_Stream;
91
92 typedef struct {
93 const char *event;
94 const char *id;
95 const char *data;
96 int32 retry_ms;
97 } Seobeo_SSE_Event;
79 98
80 // --- Router Types --- // 99 // --- Router Types --- //
81 // Forward declaration 100 // Forward declaration
82 typedef struct Seobeo_Route_Struct Seobeo_Route; 101 typedef struct Seobeo_Route_Struct Seobeo_Route;
83 102
91 typedef void (*Seobeo_Stream_Handler)( 110 typedef void (*Seobeo_Stream_Handler)(
92 Seobeo_Handle *p_client_handle, 111 Seobeo_Handle *p_client_handle,
93 Seobeo_Request_Entry *p_request_map, 112 Seobeo_Request_Entry *p_request_map,
94 Dowa_Arena *p_arena 113 Dowa_Arena *p_arena
95 ); 114 );
115
116 typedef void (*Seobeo_SSE_Handler)(
117 Seobeo_SSE_Stream *p_stream,
118 Seobeo_Request_Entry *p_request_map,
119 Dowa_Arena *p_arena
120 );
121
122 extern Seobeo_SSE_Stream *Seobeo_SSE_Server_Attach(
123 Seobeo_Handle *p_handle,
124 const char *path);
125 extern void Seobeo_SSE_Server_Detach_Handle(Seobeo_Handle *p_handle);
126 extern void Seobeo_SSE_Server_Destroy(void);
96 127
97 // --- Parse Header into Dowa Map ---// 128 // --- Parse Header into Dowa Map ---//
98 extern int Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Seobeo_Request_Entry **pp_map, Dowa_Arena *p_arena); 129 extern int Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Seobeo_Request_Entry **pp_map, Dowa_Arena *p_arena);
99 130
100 // --- Handle Request --- // 131 // --- Handle Request --- //