Update sender.js
This commit is contained in:
parent
8b5e1b644a
commit
e73aa40151
1 changed files with 51 additions and 34 deletions
85
node_modules/ws/lib/sender.js
generated
vendored
85
node_modules/ws/lib/sender.js
generated
vendored
|
@ -1,5 +1,9 @@
|
||||||
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls$" }] */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const net = require('net');
|
||||||
|
const tls = require('tls');
|
||||||
const { randomFillSync } = require('crypto');
|
const { randomFillSync } = require('crypto');
|
||||||
|
|
||||||
const PerMessageDeflate = require('./permessage-deflate');
|
const PerMessageDeflate = require('./permessage-deflate');
|
||||||
|
@ -16,8 +20,8 @@ class Sender {
|
||||||
/**
|
/**
|
||||||
* Creates a Sender instance.
|
* Creates a Sender instance.
|
||||||
*
|
*
|
||||||
* @param {net.Socket} socket The connection socket
|
* @param {(net.Socket|tls.Socket)} socket The connection socket
|
||||||
* @param {Object} extensions An object containing the negotiated extensions
|
* @param {Object} [extensions] An object containing the negotiated extensions
|
||||||
*/
|
*/
|
||||||
constructor(socket, extensions) {
|
constructor(socket, extensions) {
|
||||||
this._extensions = extensions || {};
|
this._extensions = extensions || {};
|
||||||
|
@ -37,10 +41,14 @@ class Sender {
|
||||||
* @param {Buffer} data The data to frame
|
* @param {Buffer} data The data to frame
|
||||||
* @param {Object} options Options object
|
* @param {Object} options Options object
|
||||||
* @param {Number} options.opcode The opcode
|
* @param {Number} options.opcode The opcode
|
||||||
* @param {Boolean} options.readOnly Specifies whether `data` can be modified
|
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
||||||
* @param {Boolean} options.fin Specifies whether or not to set the FIN bit
|
* modified
|
||||||
* @param {Boolean} options.mask Specifies whether or not to mask `data`
|
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
||||||
* @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit
|
* FIN bit
|
||||||
|
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
||||||
|
* `data`
|
||||||
|
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
||||||
|
* RSV1 bit
|
||||||
* @return {Buffer[]} The framed data as a list of `Buffer` instances
|
* @return {Buffer[]} The framed data as a list of `Buffer` instances
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -93,10 +101,10 @@ class Sender {
|
||||||
/**
|
/**
|
||||||
* Sends a close message to the other peer.
|
* Sends a close message to the other peer.
|
||||||
*
|
*
|
||||||
* @param {(Number|undefined)} code The status code component of the body
|
* @param {Number} [code] The status code component of the body
|
||||||
* @param {String} data The message component of the body
|
* @param {String} [data] The message component of the body
|
||||||
* @param {Boolean} mask Specifies whether or not to mask the message
|
* @param {Boolean} [mask=false] Specifies whether or not to mask the message
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
close(code, data, mask, cb) {
|
close(code, data, mask, cb) {
|
||||||
|
@ -132,8 +140,8 @@ class Sender {
|
||||||
* Frames and sends a close message.
|
* Frames and sends a close message.
|
||||||
*
|
*
|
||||||
* @param {Buffer} data The message to send
|
* @param {Buffer} data The message to send
|
||||||
* @param {Boolean} mask Specifies whether or not to mask `data`
|
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
doClose(data, mask, cb) {
|
doClose(data, mask, cb) {
|
||||||
|
@ -153,8 +161,8 @@ class Sender {
|
||||||
* Sends a ping message to the other peer.
|
* Sends a ping message to the other peer.
|
||||||
*
|
*
|
||||||
* @param {*} data The message to send
|
* @param {*} data The message to send
|
||||||
* @param {Boolean} mask Specifies whether or not to mask `data`
|
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
ping(data, mask, cb) {
|
ping(data, mask, cb) {
|
||||||
|
@ -175,9 +183,9 @@ class Sender {
|
||||||
* Frames and sends a ping message.
|
* Frames and sends a ping message.
|
||||||
*
|
*
|
||||||
* @param {Buffer} data The message to send
|
* @param {Buffer} data The message to send
|
||||||
* @param {Boolean} mask Specifies whether or not to mask `data`
|
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||||
* @param {Boolean} readOnly Specifies whether `data` can be modified
|
* @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
doPing(data, mask, readOnly, cb) {
|
doPing(data, mask, readOnly, cb) {
|
||||||
|
@ -197,8 +205,8 @@ class Sender {
|
||||||
* Sends a pong message to the other peer.
|
* Sends a pong message to the other peer.
|
||||||
*
|
*
|
||||||
* @param {*} data The message to send
|
* @param {*} data The message to send
|
||||||
* @param {Boolean} mask Specifies whether or not to mask `data`
|
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
pong(data, mask, cb) {
|
pong(data, mask, cb) {
|
||||||
|
@ -219,9 +227,9 @@ class Sender {
|
||||||
* Frames and sends a pong message.
|
* Frames and sends a pong message.
|
||||||
*
|
*
|
||||||
* @param {Buffer} data The message to send
|
* @param {Buffer} data The message to send
|
||||||
* @param {Boolean} mask Specifies whether or not to mask `data`
|
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||||
* @param {Boolean} readOnly Specifies whether `data` can be modified
|
* @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
doPong(data, mask, readOnly, cb) {
|
doPong(data, mask, readOnly, cb) {
|
||||||
|
@ -242,11 +250,15 @@ class Sender {
|
||||||
*
|
*
|
||||||
* @param {*} data The message to send
|
* @param {*} data The message to send
|
||||||
* @param {Object} options Options object
|
* @param {Object} options Options object
|
||||||
* @param {Boolean} options.compress Specifies whether or not to compress `data`
|
* @param {Boolean} [options.compress=false] Specifies whether or not to
|
||||||
* @param {Boolean} options.binary Specifies whether `data` is binary or text
|
* compress `data`
|
||||||
* @param {Boolean} options.fin Specifies whether the fragment is the last one
|
* @param {Boolean} [options.binary=false] Specifies whether `data` is binary
|
||||||
* @param {Boolean} options.mask Specifies whether or not to mask `data`
|
* or text
|
||||||
* @param {Function} cb Callback
|
* @param {Boolean} [options.fin=false] Specifies whether the fragment is the
|
||||||
|
* last one
|
||||||
|
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
||||||
|
* `data`
|
||||||
|
* @param {Function} [cb] Callback
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
send(data, options, cb) {
|
send(data, options, cb) {
|
||||||
|
@ -300,14 +312,19 @@ class Sender {
|
||||||
* Dispatches a data message.
|
* Dispatches a data message.
|
||||||
*
|
*
|
||||||
* @param {Buffer} data The message to send
|
* @param {Buffer} data The message to send
|
||||||
* @param {Boolean} compress Specifies whether or not to compress `data`
|
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
||||||
|
* `data`
|
||||||
* @param {Object} options Options object
|
* @param {Object} options Options object
|
||||||
* @param {Number} options.opcode The opcode
|
* @param {Number} options.opcode The opcode
|
||||||
* @param {Boolean} options.readOnly Specifies whether `data` can be modified
|
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
||||||
* @param {Boolean} options.fin Specifies whether or not to set the FIN bit
|
* modified
|
||||||
* @param {Boolean} options.mask Specifies whether or not to mask `data`
|
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
||||||
* @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit
|
* FIN bit
|
||||||
* @param {Function} cb Callback
|
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
||||||
|
* `data`
|
||||||
|
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
||||||
|
* RSV1 bit
|
||||||
|
* @param {Function} [cb] Callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
dispatch(data, compress, options, cb) {
|
dispatch(data, compress, options, cb) {
|
||||||
|
@ -374,7 +391,7 @@ class Sender {
|
||||||
* Sends a frame.
|
* Sends a frame.
|
||||||
*
|
*
|
||||||
* @param {Buffer[]} list The frame to send
|
* @param {Buffer[]} list The frame to send
|
||||||
* @param {Function} cb Callback
|
* @param {Function} [cb] Callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
sendFrame(list, cb) {
|
sendFrame(list, cb) {
|
||||||
|
|
Loading…
Reference in a new issue