2#ifndef CWIST_NET_HTTP_SSE_H
3#define CWIST_NET_HTTP_SSE_H
23 int retry_ms,
const char *data);
30 int retry_ms,
const char *data);
36#define CWIST_SSE_EVENT(payload) \
37 ((cwist_sse_event_t){.event = NULL, .id = NULL, .retry_ms = -1, .data = (payload)})
38#define CWIST_SSE_NAMED(event_name, payload) \
39 ((cwist_sse_event_t){.event = (event_name), .id = NULL, .retry_ms = -1, .data = (payload)})
40#define CWIST_SSE_JSON(payload) CWIST_SSE_NAMED("message", (payload))
41#define CWIST_SSE_RESPONSE_SEND(res, event) cwist_sse_response_write((res), &(event))
42#define CWIST_SSE_STREAM_SEND(stream, event) cwist_sse_stream_write((stream), &(event))
HTTP Protocol Definitions and Helpers.
cwist_error_t cwist_sse_response_init(cwist_http_response *res)
Prepare a response buffer for a Server-Sent Events reply.
cwist_error_t cwist_sse_stream_comment(cwist_sse_stream_t *stream, const char *comment)
Send an SSE comment line on a live stream.
cwist_error_t cwist_sse_response_comment(cwist_http_response *res, const char *comment)
Append an SSE comment line to a response buffer.
struct cwist_sse_stream cwist_sse_stream_t
cwist_sse_stream_t * cwist_sse_stream_open(cwist_http_request *req)
Upgrade a request connection to a live SSE stream.
cwist_error_t cwist_sse_response_event(cwist_http_response *res, const char *event, const char *id, int retry_ms, const char *data)
Append a formatted SSE event to a response buffer.
cwist_error_t cwist_sse_stream_send(cwist_sse_stream_t *stream, const char *event, const char *id, int retry_ms, const char *data)
Send a formatted SSE event on a live stream.
void cwist_sse_stream_close(cwist_sse_stream_t *stream)
Close a live SSE stream and release its resources.
cwist_error_t cwist_sse_response_write(cwist_http_response *res, const cwist_sse_event_t *event)
Append an SSE event described by a cwist_sse_event_t to a response.
struct cwist_sse_event cwist_sse_event_t
cwist_error_t cwist_sse_stream_write(cwist_sse_stream_t *stream, const cwist_sse_event_t *event)
Send an SSE event described by a cwist_sse_event_t on a stream.
Integrated error structure used throughout the system.
HTTP Response Object. Supports standard string body or Zero-Copy pointer body.