ServerSentEvent C Reference Documentation

ServerSentEvent

Represents a server-sent event (SSE) received from an HTTP text/event-stream.

Create/Dispose

HCkServerSentEvent CkServerSentEvent_Create(void);

Creates an instance of the HCkServerSentEvent object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.

void CkServerSentEvent_Dispose(HCkServerSentEvent handle);

Objects created by calling CkServerSentEvent_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkServerSentEvent_Dispose.

Properties

void CkServerSentEvent_getData(HCkServerSentEvent cHandle, HCkString retval);

const char *CkServerSentEvent_data(HCkServerSentEvent cHandle);

Introduced in version 9.5.0.58

The data for the server-side event. (If the "data" field was empty, then this will be empty.)

void CkServerSentEvent_getEventName(HCkServerSentEvent cHandle, HCkString retval);

const char *CkServerSentEvent_eventName(HCkServerSentEvent cHandle);

Introduced in version 9.5.0.58

The name of the server-side event. (If the "event" field was not present, then this will be empty.)

void CkServerSentEvent_getLastEventId(HCkServerSentEvent cHandle, HCkString retval);

const char *CkServerSentEvent_lastEventId(HCkServerSentEvent cHandle);

Introduced in version 9.5.0.58

The content of the "id" field, if present.

int CkServerSentEvent_getRetry(HCkServerSentEvent cHandle);

Introduced in version 9.5.0.58

The integer value of the "retry" field, if present. Otherwise 0.

BOOL CkServerSentEvent_getUtf8(HCkServerSentEvent cHandle);

void CkServerSentEvent_putUtf8(HCkServerSentEvent cHandle, BOOL newVal);

When set to TRUE, all "const char *" arguments are interpreted as utf-8 strings. If set to FALSE (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to TRUE, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to FALSE, all "const char *" return values are ANSI strings.

Methods

BOOL CkServerSentEvent_LoadEvent(HCkServerSentEvent cHandle, const char *eventText);

Introduced in version 9.5.0.58

Loads the multi-line event text into this object. For example, the eventText for a Firebase event might look like this:

event: put
data: {"path": "/c", "data": {"foo": true, "bar": false}}

Returns TRUE for success, FALSE for failure.

Firebase Receive Server-Sent Events (text/event-stream)