Class: SseEmitter

SseEmitter(timeoutopt)

An object for sending Server-Sent Events.

Constructor

new SseEmitter(timeoutopt)

Creates a new SSE emitter with an optional timeout.

Parameters:
Name Type Attributes Description
timeout number <optional>

The timeout in milliseconds after which the connection will be closed.

Classes

SseEmitter

Members

timeout :number|undefined

The timeout in milliseconds after which the connection will be closed or undefined if no timeout is set.

Type:
  • number | undefined

Methods

extendResponse(outputMessage)

Sets and extends the response object for sending Server-Sent Events.

Parameters:
Name Type Description
outputMessage http.ServerResponse

The response object to use.

send(event)

Sends a SSE event.

Parameters:
Name Type Description
event object

The event to send.

Properties
Name Type Attributes Description
id string <optional>

Add a SSE "id" line.

name string <optional>

Add a SSE "event" line.

reconnectTime number <optional>

Add a SSE "retry" line.

comment string <optional>

Add a SSE "comment" line.

data string | object <optional>

Add a SSE "data" line.

simulateTimeout()

Simulates a timeout.