Open masx200 opened 4 years ago
public send(data: Message) {
if (this._ws && this._ws.readyState === this.OPEN) {
this._debug('send', data);
this._ws.send(data);
} else {
const {maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages} = this._options;
if (this._messageQueue.length < maxEnqueuedMessages) {
this._debug('enqueue', data);
this._messageQueue.push(data);
}
throw Error("The connection is not currently OPEN.")
}
}
One of the main features of this library is that it masks brief disconnects and queues up messages to be sent when reconnected. If you want an error on a send failure then you should be using the standard websocket API.
The
send ()
method is inconsistent with the websocket standard. When the connection is not in theopen
state, an error should be reported.https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
Exceptions thrown
INVALID_STATE_ERR
The connection is not currently
OPEN
.