EventSource Module

A module that implements the Server-Sent Event specification, which can be read at www.w3.org/TR/eventsource.

Types

Type Description

Message

A container data type for the output events

Functions and values

Function or value Description

out <<. data

Full Usage: out <<. data

Parameters:
Returns: Task<unit>

Same as `async_write`; convenience function.

out : Connection
data : string
Returns: Task<unit>

asyncWrite out data

Full Usage: asyncWrite out data

Parameters:
Returns: Task<unit>

Helper function that writes a string of data. Most often you are better off using the `send` function and give it a message, as this will ensure the proper framing is used. However, if you have a desire to write raw data, this function overrides the Socket.async_write function so that you will be writing UTF8 data only, as per the specification.

out : Connection
data : string
Returns: Task<unit>

comment out cmt

Full Usage: comment out cmt

Parameters:
Returns: Task<unit>

"If the line starts with a U+003A COLON character (:) - Ignore the line." Writes a comment to the stream

out : Connection
cmt : string
Returns: Task<unit>

data out data

Full Usage: data out data

Parameters:
Returns: Task<unit>

"If the field name is 'data' - Append the field value to the data buffer, then append a single U+000A LINE FEED (LF) character to the data buffer." Write a piece of data as part of the event

out : Connection
data : string
Returns: Task<unit>

dispatch out

Full Usage: dispatch out

Parameters:
Returns: Task<unit>

"If the line is empty (a blank line) - dispatch the event." Dispatches the event properly to the browser.

out : Connection
Returns: Task<unit>

esId out lastEventId

Full Usage: esId out lastEventId

Parameters:
Returns: Task<unit>

"If the field name is 'id' - Set the last event ID buffer to the field value." Sets the last event id in the stream.

out : Connection
lastEventId : string
Returns: Task<unit>

eventType out eventType

Full Usage: eventType out eventType

Parameters:
Returns: Task<unit>

"If the field name is 'event' - Set the event type buffer to field value." Writes the event type to the stream

out : Connection
eventType : string
Returns: Task<unit>

handShake fCont

Full Usage: handShake fCont

Parameters:
Returns: WebPart

This function composes the passed function f with the hand-shake required to start a new event-stream protocol session with the browser.

fCont : Connection -> Task<unit>
Returns: WebPart

retry out retry

Full Usage: retry out retry

Parameters:
Returns: Task<unit>

Sets the option for the EventSource instance, of how long to wait in ms until a new connection is spawned as a retry.

out : Connection
retry : uint32
Returns: Task<unit>

send out msg

Full Usage: send out msg

Parameters:
Returns: Task<unit>

send a message containing data to the output stream

out : Connection
msg : Message
Returns: Task<unit>