Interface: MessageClient

MessageClient

An interface for a streaming message client.

Emits the following events:

  • open, Event
  • message, MessageEvent
  • error, Event

It is used for wrappers around EventSource and WebSocket, also for long polling.

Members

(readonly) isConnected :boolean

Returns whether the client is connected.

Type:
  • boolean

(readonly) url :string

Returns the server URL.

Type:
  • string

Methods

(async) close()

Closes the connection.

(async) connect(url)

Connects to the server.

Parameters:
Name Type Description
url URL | string

The server URL to connect to.

(async) send(message, type)

Sends a message to the server.

This is an optional method for streams with bidirectional communication.

Parameters:
Name Type Description
message string

The message to send.

type string

The optional message type.