Sse¶
-
class
Sse¶ Wrapper around the Request object for handeling Server Sent Event replies
-
tx: cosock.channel¶
-
static
new(res, keepalive)¶ Wrap a Response in a new server sent event handle. This will spawn
a cosock task that will manage the keepalive messages along with any the sending of any intentional events or data
if keepalive is a number it will be used to determine the wait between events otherwise if truthy, it will default to set to 15 seconds
Note: This requires that the server is configured with the async property set to true
- Parameters
res (Response) – The response to wrap
keepalive (boolean or integer) – if a number the maximum number of seconds to wait between events to send an empty comment
- Returns
A handle to the server sent event task
- Return type
-
-
class
Event¶ A single Server Sent Event, this implements a builder pattern, so after calling new all other methods return the instance being updated.
-
_id: str or nil¶
-
_comment: str or nil¶
-
_data: str or nil¶
-
_retry: number or nil¶
-
to_string()¶ Serialize this event into the sse format
- Return type
any
-