@@ -192,6 +192,9 @@ class WebSocket extends EventEmitter {
192192 * @param {Duplex } socket The network socket between the server and client
193193 * @param {Buffer } head The first packet of the upgraded stream
194194 * @param {Object } options Options object
195+ * @param {Boolean } [options.allowMultipleEventsPerMicrotask=false] Specifies
196+ * whether or not to process more than one of the `'message'`, `'ping'`,
197+ * and `'pong'` events per microtask
195198 * @param {Function } [options.generateMask] The function used to generate the
196199 * masking key
197200 * @param {Number } [options.maxPayload=0] The maximum allowed message size
@@ -201,6 +204,7 @@ class WebSocket extends EventEmitter {
201204 */
202205 setSocket ( socket , head , options ) {
203206 const receiver = new Receiver ( {
207+ allowMultipleEventsPerMicrotask : options . allowMultipleEventsPerMicrotask ,
204208 binaryType : this . binaryType ,
205209 extensions : this . _extensions ,
206210 isServer : this . _isServer ,
@@ -618,6 +622,9 @@ module.exports = WebSocket;
618622 * @param {(String|URL) } address The URL to which to connect
619623 * @param {Array } protocols The subprotocols
620624 * @param {Object } [options] Connection options
625+ * @param {Boolean } [options.allowMultipleEventsPerMicrotask=false] Specifies
626+ * whether or not to process more than one of the `'message'`, `'ping'`,
627+ * and `'pong'` events per microtask
621628 * @param {Function } [options.finishRequest] A function which can be used to
622629 * customize the headers of each http request before it is sent
623630 * @param {Boolean } [options.followRedirects=false] Whether or not to follow
@@ -642,6 +649,7 @@ module.exports = WebSocket;
642649 */
643650function initAsClient ( websocket , address , protocols , options ) {
644651 const opts = {
652+ allowMultipleEventsPerMicrotask : false ,
645653 protocolVersion : protocolVersions [ 1 ] ,
646654 maxPayload : 100 * 1024 * 1024 ,
647655 skipUTF8Validation : false ,
@@ -993,6 +1001,7 @@ function initAsClient(websocket, address, protocols, options) {
9931001 }
9941002
9951003 websocket . setSocket ( socket , head , {
1004+ allowMultipleEventsPerMicrotask : opts . allowMultipleEventsPerMicrotask ,
9961005 generateMask : opts . generateMask ,
9971006 maxPayload : opts . maxPayload ,
9981007 skipUTF8Validation : opts . skipUTF8Validation
0 commit comments