Skip to content

Commit

Permalink
Option to not buffer when sending
Browse files Browse the repository at this point in the history
When sending data, we need an option to not buffer the message.
  • Loading branch information
HardlyMirage committed May 31, 2020
1 parent 05a2f7c commit 0148d37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reconnecting-websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ export default class ReconnectingWebSocket {
/**
* Enqueue specified data to be transmitted to the server over the WebSocket connection
*/
public send(data: Message) {
public send(data: Message, bufferOnFailure = true) {
if (this._ws && this._ws.readyState === this.OPEN) {
this._debug('send', data);
this._ws.send(data);
} else {
} else if (bufferOnFailure) {
const {maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages} = this._options;
if (this._messageQueue.length < maxEnqueuedMessages) {
this._debug('enqueue', data);
Expand Down

0 comments on commit 0148d37

Please sign in to comment.