Class: SseClient

SseClient(eventSourceConstructor)

A client for the server-sent events protocol.

Constructor

new SseClient(eventSourceConstructor)

The constructor is for internal use. Use the factory methods instead.

Parameters:
Name Type Description
eventSourceConstructor EventSourceConstructor
Implements:
See:

Classes

SseClient

Members

(readonly) isConnected :boolean

Returns whether the client is connected.

Type:
  • boolean
Implements:

(readonly) url :string

Returns the server URL.

Type:
  • string
Implements:

Methods

(async) close()

Closes the connection.

Implements:

(async) connect(url, eventNameopt)

Connects to the server.

Parameters:
Name Type Attributes Default Description
url URL | string

The server URL to connect to.

eventName string <optional>
message

The optional event type to listen to.

Implements:

simulateError()

Simulates an error event.

simulateMessage(message, eventNameopt, lastEventIdopt)

Simulates a message event from the server.

Parameters:
Name Type Attributes Default Description
message string

The message to receive.

eventName string <optional>
message

The optional event type.

lastEventId string <optional>

The optional last event ID.

(static) create() → {SseClient}

Creates a SSE client.

Returns:

A new SSE client.

Type
SseClient

(static) createNull() → {SseClient}

Creates a nulled SSE client.

Returns:

A new SSE client.

Type
SseClient