Creates a new websocket.
to connect to.
Optional
protocols: string | string[]optional protocols to use.
Optional
options: WebsocketOptionsoptional options to use.
Getter for the binaryType of the underlying websocket.
the binaryType of the underlying websocket.
Setter for the binaryType of the underlying websocket.
to set, 'blob' or 'arraybuffer'.
Getter for the buffer.
the buffer, or undefined if none was provided.
Getter for the bufferedAmount of the underlying websocket.
the bufferedAmount of the underlying websocket.
Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
true if the websocket was closed by the user, false otherwise.
Getter for the extensions of the underlying websocket.
the extensions of the underlying websocket.
Getter for the instantReconnect.
the instantReconnect, or undefined if none was provided.
Getter for the last 'open' event, e.g. the last time the websocket was connected.
the last 'open' event, or undefined if the websocket was never connected.
Getter for the maxRetries.
the maxRetries, or undefined if none was provided (no limit).
Getter for the protocols.
the protocols, or undefined if none were provided.
Getter for the readyState of the underlying websocket.
the readyState of the underlying websocket.
Getter for the underlying websocket. This can be used to access the browser's native websocket directly.
the underlying websocket.
Getter for the url.
the url.
Adds an event listener for the given event-type.
of the event to add the listener for.
to add.
Optional
options: WebsocketEventListenerOptionsto use when adding the listener.
Close the websocket. No connection-retry will be attempted after this.
Optional
code: numberoptional close code.
Optional
reason: stringoptional close reason.
Removes one or more event listener for the given event-type that match the given listener and options.
of the event to remove the listener for.
to remove.
Optional
options: WebsocketEventListenerOptionsthat were used when the listener was added.
Sends data over the websocket.
If the websocket is not connected and a buffer was provided on creation, the data will be added to the buffer. If no buffer was provided or the websocket was closed by the user, the data will be dropped.
to send.
A websocket wrapper that can be configured to reconnect automatically and buffer messages when the websocket is not connected.