core.reconnectingwebsocket | Medplum

ReconnectingWebSocket class

Signature:

export declare class ReconnectingWebSocket<WS extends IWebSocket = WebSocket> extends TypedEventTarget<WebSocketEventMap> implements IReconnectingWebSocket

Extends: TypedEventTarget < WebSocketEventMap >

Implements: IReconnectingWebSocket

Constructors

Constructor Modifiers Description
(constructor)(url, protocols, options) Constructs a new instance of the ReconnectingWebSocket class

Properties

Property Modifiers Type Description
_options protected Options
_protocols? protected ProtocolsProvider (Optional)
_url protected string
binaryType WS['binaryType']
bufferedAmount readonly number
CLOSED readonly number
CLOSED static
readonly
number
CLOSING readonly number
CLOSING static
readonly
number
CONNECTING readonly number
CONNECTING static
readonly
number
extensions readonly string
onclose ((event: CloseEvent) => void) An event listener to be called when the WebSocket connection's readyState changes to CLOSED
onerror ((event: ErrorEvent) => void) An event listener to be called when an error occurs
onmessage ((event: MessageEvent) => void) An event listener to be called when a message is received from the server
onopen ((event: Event) => void) An event listener to be called when the WebSocket connection's readyState changes to OPEN; this indicates that the connection is ready to send and receive data
OPEN readonly number
OPEN static
readonly
number
protocol readonly string
readyState readonly number
retryCount readonly number
shouldReconnect readonly boolean
url readonly string

Methods

Method Modifiers Description
close(code, reason) Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing
reconnect(code, reason) Closes the WebSocket connection or connection attempt and connects again. Resets retry counter;
send(data) Enqueue specified data to be transmitted to the server over the WebSocket connection