Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jan 6, 2022
1 parent e4bd7b9 commit c285e36
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Sender {

if (typeof data === 'string') {
if (!options.mask || skipMasking) {
if (!dataLength) {
if (dataLength == null) {
dataLength = Buffer.byteLength(data);
}
} else {
Expand Down Expand Up @@ -207,7 +207,7 @@ class Sender {
mask,
maskBuffer: this._maskBuffer,
generateMask: this._generateMask,
readOnly: false
readOnly: true
}),
cb
);
Expand All @@ -229,9 +229,9 @@ class Sender {
}

if (this._deflating) {
this.enqueue([this.doPing, data, mask, true, cb]);
this.enqueue([this.doPing, data, mask, payloadLength, cb]);
} else {
this.doPing(data, mask, true, cb);
this.doPing(data, mask, payloadLength, cb);
}
}

Expand All @@ -240,11 +240,10 @@ class Sender {
*
* @param {Buffer} data The message to send
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
* @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
* @param {Function} [cb] Callback
* @private
*/
doPing(data, mask, readOnly, cb) {
doPing(data, mask, payloadLength, cb) {
this.sendFrame(
Sender.frame(data, {
fin: true,
Expand All @@ -253,7 +252,8 @@ class Sender {
mask,
maskBuffer: this._maskBuffer,
generateMask: this._generateMask,
readOnly
payloadLength,
readOnly: true
}),
cb
);
Expand All @@ -275,9 +275,9 @@ class Sender {
}

if (this._deflating) {
this.enqueue([this.doPong, data, mask, true, cb]);
this.enqueue([this.doPong, data, mask, payloadLength, cb]);
} else {
this.doPong(data, mask, true, cb);
this.doPong(data, mask, payloadLength, cb);
}
}

Expand All @@ -286,11 +286,10 @@ class Sender {
*
* @param {Buffer} data The message to send
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
* @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
* @param {Function} [cb] Callback
* @private
*/
doPong(data, mask, readOnly, cb) {
doPong(data, mask, payloadLength, cb) {
this.sendFrame(
Sender.frame(data, {
fin: true,
Expand All @@ -299,7 +298,8 @@ class Sender {
mask,
maskBuffer: this._maskBuffer,
generateMask: this._generateMask,
readOnly
payloadLength,
readOnly: true
}),
cb
);
Expand Down Expand Up @@ -360,7 +360,8 @@ class Sender {
mask: options.mask,
maskBuffer: this._maskBuffer,
generateMask: this._generateMask,
payloadLength
payloadLength,
readOnly: true
};

if (this._deflating) {
Expand All @@ -377,7 +378,8 @@ class Sender {
mask: options.mask,
maskBuffer: this._maskBuffer,
generateMask: this._generateMask,
payloadLength
payloadLength,
readOnly: true
}),
cb
);
Expand Down

0 comments on commit c285e36

Please sign in to comment.