diff --git a/doc/ws.md b/doc/ws.md index 22c712034..08d70cc7a 100644 --- a/doc/ws.md +++ b/doc/ws.md @@ -64,23 +64,23 @@ This class represents a WebSocket server. It extends the `EventEmitter`. ### new WebSocketServer(options[, callback]) - `options` {Object} - - `host` {String} The hostname where to bind the server. - - `port` {Number} The port where to bind the server. - `backlog` {Number} The maximum length of the queue of pending connections. - - `server` {http.Server|https.Server} A pre-created Node.js HTTP/S server. - - `verifyClient` {Function} A function which can be used to validate incoming - connections. See description below. (Usage is discouraged: see - [Issue #337](https://github.com/websockets/ws/issues/377#issuecomment-462152231)) + - `clientTracking` {Boolean} Specifies whether or not to track clients. - `handleProtocols` {Function} A function which can be used to handle the WebSocket subprotocols. See description below. - - `path` {String} Accept only connections matching this path. + - `host` {String} The hostname where to bind the server. + - `maxPayload` {Number} The maximum allowed message size in bytes. - `noServer` {Boolean} Enable no server mode. - - `clientTracking` {Boolean} Specifies whether or not to track clients. + - `path` {String} Accept only connections matching this path. - `perMessageDeflate` {Boolean|Object} Enable/disable permessage-deflate. - - `maxPayload` {Number} The maximum allowed message size in bytes. + - `port` {Number} The port where to bind the server. + - `server` {http.Server|https.Server} A pre-created Node.js HTTP/S server. - `skipUTF8Validation` {Boolean} Specifies whether or not to skip UTF-8 validation for text and close messages. Defaults to `false`. Set to `true` only if clients are trusted. + - `verifyClient` {Function} A function which can be used to validate incoming + connections. See description below. (Usage is discouraged: see + [Issue #337](https://github.com/websockets/ws/issues/377#issuecomment-462152231)) - `callback` {Function} Create a new server instance. One and only one of `port`, `server` or `noServer` @@ -269,13 +269,13 @@ This class represents a WebSocket. It extends the `EventEmitter`. `false`. - `handshakeTimeout` {Number} Timeout in milliseconds for the handshake request. This is reset after every redirection. + - `maxPayload` {Number} The maximum allowed message size in bytes. - `maxRedirects` {Number} The maximum number of redirects allowed. Defaults to 10. - - `perMessageDeflate` {Boolean|Object} Enable/disable permessage-deflate. - - `protocolVersion` {Number} Value of the `Sec-WebSocket-Version` header. - `origin` {String} Value of the `Origin` or `Sec-WebSocket-Origin` header depending on the `protocolVersion`. - - `maxPayload` {Number} The maximum allowed message size in bytes. + - `perMessageDeflate` {Boolean|Object} Enable/disable permessage-deflate. + - `protocolVersion` {Number} Value of the `Sec-WebSocket-Version` header. - `skipUTF8Validation` {Boolean} Specifies whether or not to skip UTF-8 validation for text and close messages. Defaults to `false`. Set to `true` only if the server is trusted. @@ -491,14 +491,14 @@ only removes listeners added with - `data` {Array|Number|Object|String|ArrayBuffer|Buffer|DataView|TypedArray} The data to send. - `options` {Object} - - `compress` {Boolean} Specifies whether `data` should be compressed or not. - Defaults to `true` when permessage-deflate is enabled. - `binary` {Boolean} Specifies whether `data` should be sent as a binary or not. Default is autodetected. - - `mask` {Boolean} Specifies whether `data` should be masked or not. Defaults - to `true` when `websocket` is not a server client. + - `compress` {Boolean} Specifies whether `data` should be compressed or not. + Defaults to `true` when permessage-deflate is enabled. - `fin` {Boolean} Specifies whether `data` is the last fragment of a message or not. Defaults to `true`. + - `mask` {Boolean} Specifies whether `data` should be masked or not. Defaults + to `true` when `websocket` is not a server client. - `callback` {Function} An optional callback which is invoked when `data` is written out. diff --git a/lib/permessage-deflate.js b/lib/permessage-deflate.js index 7fe9459ff..9e6003d07 100644 --- a/lib/permessage-deflate.js +++ b/lib/permessage-deflate.js @@ -30,22 +30,22 @@ class PerMessageDeflate { * Creates a PerMessageDeflate instance. * * @param {Object} [options] Configuration options - * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept - * disabling of server context takeover + * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support + * for, or request, a custom client window size * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/ * acknowledge disabling of client context takeover + * @param {Number} [options.concurrencyLimit=10] The number of concurrent + * calls to zlib * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the * use of a custom server window size - * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support - * for, or request, a custom client window size + * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept + * disabling of server context takeover + * @param {Number} [options.threshold=1024] Size (in bytes) below which + * messages should not be compressed * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on * deflate * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on * inflate - * @param {Number} [options.threshold=1024] Size (in bytes) below which - * messages should not be compressed - * @param {Number} [options.concurrencyLimit=10] The number of concurrent - * calls to zlib * @param {Boolean} [isServer=false] Create the instance in either server or * client mode * @param {Number} [maxPayload=0] The maximum allowed message length diff --git a/lib/sender.js b/lib/sender.js index 4f46f4d88..15df9d065 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -40,13 +40,13 @@ class Sender { * * @param {Buffer} data The data to frame * @param {Object} options Options object - * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified * @param {Boolean} [options.fin=false] Specifies whether or not to set the * FIN bit * @param {Boolean} [options.mask=false] Specifies whether or not to mask * `data` + * @param {Number} options.opcode The opcode + * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be + * modified * @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 @@ -255,10 +255,10 @@ class Sender { * * @param {*} data The message to send * @param {Object} options Options object - * @param {Boolean} [options.compress=false] Specifies whether or not to - * compress `data` * @param {Boolean} [options.binary=false] Specifies whether `data` is binary * or text + * @param {Boolean} [options.compress=false] Specifies whether or not to + * compress `data` * @param {Boolean} [options.fin=false] Specifies whether the fragment is the * last one * @param {Boolean} [options.mask=false] Specifies whether or not to mask @@ -321,12 +321,12 @@ class Sender { * `data` * @param {Object} options Options object * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified * @param {Boolean} [options.fin=false] Specifies whether or not to set the * FIN bit * @param {Boolean} [options.mask=false] Specifies whether or not to mask * `data` + * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be + * modified * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the * RSV1 bit * @param {Function} [cb] Callback diff --git a/lib/websocket.js b/lib/websocket.js index 8d8f913e4..f0b6eb531 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -378,10 +378,10 @@ class WebSocket extends EventEmitter { * * @param {*} data The message to send * @param {Object} [options] Options object - * @param {Boolean} [options.compress] Specifies whether or not to compress - * `data` * @param {Boolean} [options.binary] Specifies whether `data` is binary or * text + * @param {Boolean} [options.compress] Specifies whether or not to compress + * `data` * @param {Boolean} [options.fin=true] Specifies whether the fragment is the * last one * @param {Boolean} [options.mask] Specifies whether or not to mask `data` @@ -565,20 +565,20 @@ module.exports = WebSocket; * @param {(String|URL)} address The URL to which to connect * @param {Array} protocols The subprotocols * @param {Object} [options] Connection options - * @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable - * permessage-deflate + * @param {Boolean} [options.followRedirects=false] Whether or not to follow + * redirects * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the * handshake request - * @param {Number} [options.protocolVersion=13] Value of the - * `Sec-WebSocket-Version` header - * @param {String} [options.origin] Value of the `Origin` or - * `Sec-WebSocket-Origin` header * @param {Number} [options.maxPayload=104857600] The maximum allowed message * size - * @param {Boolean} [options.followRedirects=false] Whether or not to follow - * redirects * @param {Number} [options.maxRedirects=10] The maximum number of redirects * allowed + * @param {String} [options.origin] Value of the `Origin` or + * `Sec-WebSocket-Origin` header + * @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable + * permessage-deflate + * @param {Number} [options.protocolVersion=13] Value of the + * `Sec-WebSocket-Version` header * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or * not to skip UTF-8 validation for text and close messages * @private