@@ -103,7 +103,7 @@ This class represents a WebSocket server. It extends the `EventEmitter`.
103
103
Create a new server instance. One and only one of ` port ` , ` server ` or ` noServer `
104
104
must be provided or an error is thrown. An HTTP server is automatically created,
105
105
started, and used if ` port ` is set. To use an external HTTP/S server instead,
106
- specify only ` server ` or ` noServer ` . In this case the HTTP/S server must be
106
+ specify only ` server ` or ` noServer ` . In this case, the HTTP/S server must be
107
107
started manually. The "noServer" mode allows the WebSocket server to be
108
108
completely detached from the HTTP/S server. This makes it possible, for example,
109
109
to share a single HTTP/S server between multiple WebSocket servers.
@@ -112,8 +112,8 @@ to share a single HTTP/S server between multiple WebSocket servers.
112
112
> authentication in the ` 'upgrade' ` event of the HTTP server. See examples for
113
113
> more details.
114
114
115
- If ` verifyClient ` is not set then the handshake is automatically accepted. If it
116
- has a single parameter then ` ws ` will invoke it with the following argument:
115
+ If ` verifyClient ` is not set, then the handshake is automatically accepted. If
116
+ it has a single parameter, then ` ws ` will invoke it with the following argument:
117
117
118
118
- ` info ` {Object}
119
119
- ` origin ` {String} The value in the Origin header indicated by the client.
@@ -124,19 +124,19 @@ has a single parameter then `ws` will invoke it with the following argument:
124
124
The return value (` Boolean ` ) of the function determines whether or not to accept
125
125
the handshake.
126
126
127
- If ` verifyClient ` has two parameters then ` ws ` will invoke it with the following
128
- arguments:
127
+ If ` verifyClient ` has two parameters, then ` ws ` will invoke it with the
128
+ following arguments:
129
129
130
130
- ` info ` {Object} Same as above.
131
131
- ` cb ` {Function} A callback that must be called by the user upon inspection of
132
132
the ` info ` fields. Arguments in this callback are:
133
133
- ` result ` {Boolean} Whether or not to accept the handshake.
134
- - ` code ` {Number} When ` result ` is ` false ` this field determines the HTTP
134
+ - ` code ` {Number} When ` result ` is ` false ` , this field determines the HTTP
135
135
error status code to be sent to the client.
136
- - ` name ` {String} When ` result ` is ` false ` this field determines the HTTP
136
+ - ` name ` {String} When ` result ` is ` false ` , this field determines the HTTP
137
137
reason phrase.
138
- - ` headers ` {Object} When ` result ` is ` false ` this field determines additional
139
- HTTP headers to be sent to the client. For example,
138
+ - ` headers ` {Object} When ` result ` is ` false ` , this field determines
139
+ additional HTTP headers to be sent to the client. For example,
140
140
` { 'Retry-After': 120 } ` .
141
141
142
142
` handleProtocols ` takes two arguments:
@@ -146,15 +146,15 @@ arguments:
146
146
- ` request ` {http.IncomingMessage} The client HTTP GET request.
147
147
148
148
The returned value sets the value of the ` Sec-WebSocket-Protocol ` header in the
149
- HTTP 101 response. If returned value is ` false ` the header is not added in the
149
+ HTTP 101 response. If returned value is ` false ` , the header is not added in the
150
150
response.
151
151
152
- If ` handleProtocols ` is not set then the first of the client's requested
152
+ If ` handleProtocols ` is not set, then the first of the client's requested
153
153
subprotocols is used.
154
154
155
155
` perMessageDeflate ` can be used to control the behavior of [ permessage-deflate
156
156
extension] [ permessage-deflate ] . The extension is disabled when ` false ` (default
157
- value). If an object is provided then that is extension parameters:
157
+ value). If an object is provided, then that is extension parameters:
158
158
159
159
- ` serverNoContextTakeover ` {Boolean} Whether to use context takeover or not.
160
160
- ` clientNoContextTakeover ` {Boolean} Acknowledge disabling of client context
@@ -171,8 +171,8 @@ value). If an object is provided then that is extension parameters:
171
171
above this limit will be queued. Default 10. You usually won't need to touch
172
172
this option. See [ this issue] [ concurrency-limit ] for more details.
173
173
174
- If a property is empty then either an offered configuration or a default value
175
- is used. When sending a fragmented message the length of the first fragment is
174
+ If a property is empty, then either an offered configuration or a default value
175
+ is used. When sending a fragmented message, the length of the first fragment is
176
176
compared to the threshold. This determines if compression is used for the entire
177
177
message.
178
178
@@ -248,7 +248,7 @@ created internally. If an external HTTP server is used via the `server` or
248
248
` noServer ` constructor options, it must be closed manually. Existing connections
249
249
are not closed automatically. The server emits a ` 'close' ` event when all
250
250
connections are closed unless an external HTTP server is used and client
251
- tracking is disabled. In this case the ` 'close' ` event is emitted in the next
251
+ tracking is disabled. In this case, the ` 'close' ` event is emitted in the next
252
252
tick. The optional callback is called when the ` 'close' ` event occurs and
253
253
receives an ` Error ` if the server is already closed.
254
254
@@ -273,7 +273,7 @@ If the upgrade is successful, the `callback` is called with two arguments:
273
273
274
274
- ` request ` {http.IncomingMessage} The client HTTP GET request.
275
275
276
- See if a given request should be handled by this server. By default this method
276
+ See if a given request should be handled by this server. By default, this method
277
277
validates the pathname of the request, matching it against the ` path ` option if
278
278
provided. The return value, ` true ` or ` false ` , determines whether or not to
279
279
accept the handshake.
@@ -305,12 +305,12 @@ This class represents a WebSocket. It extends the `EventEmitter`.
305
305
tick. To improve compatibility with the WHATWG standard, the default value
306
306
is ` false ` . Setting it to ` true ` improves performance slightly.
307
307
- ` finishRequest ` {Function} A function which can be used to customize the
308
- headers of each http request before it is sent. See description below.
308
+ headers of each HTTP request before it is sent. See description below.
309
309
- ` followRedirects ` {Boolean} Whether or not to follow redirects. Defaults to
310
310
` false ` .
311
311
- ` generateMask ` {Function} The function used to generate the masking key. It
312
312
takes a ` Buffer ` that must be filled synchronously and is called before a
313
- message is sent, for each message. By default the buffer is filled with
313
+ message is sent, for each message. By default, the buffer is filled with
314
314
cryptographically strong random bytes.
315
315
- ` handshakeTimeout ` {Number} Timeout in milliseconds for the handshake
316
316
request. This is reset after every redirection.
@@ -343,7 +343,7 @@ context takeover.
343
343
344
344
for each HTTP GET request (the initial one and any caused by redirects) when it
345
345
is ready to be sent, to allow for last minute customization of the headers. If
346
- ` finishRequest ` is set then it has the responsibility to call ` request.end() `
346
+ ` finishRequest ` is set, then it has the responsibility to call ` request.end() `
347
347
once it is done setting request headers. This is intended for niche use-cases
348
348
where some headers can't be provided in advance e.g. because they depend on the
349
349
underlying socket.
@@ -479,7 +479,7 @@ The number of bytes of data that have been queued using calls to `send()` but
479
479
not yet transmitted to the network. This deviates from the HTML standard in the
480
480
following ways:
481
481
482
- 1 . If the data is immediately sent the value is ` 0 ` .
482
+ 1 . If the data is immediately sent, the value is ` 0 ` .
483
483
1 . All framing bytes are included.
484
484
485
485
### websocket.close([ code[ , reason]] )
@@ -610,7 +610,7 @@ state is `CONNECTING`.
610
610
611
611
### websocket.terminate()
612
612
613
- Forcibly close the connection. Internally this calls [ ` socket.destroy() ` ] [ ] .
613
+ Forcibly close the connection. Internally, this calls [ ` socket.destroy() ` ] [ ] .
614
614
615
615
### websocket.url
616
616
@@ -631,12 +631,12 @@ given `WebSocket`.
631
631
632
632
### WS_NO_BUFFER_UTIL
633
633
634
- When set to a non empty value, prevents the optional ` bufferutil ` dependency
634
+ When set to a non- empty value, prevents the optional ` bufferutil ` dependency
635
635
from being required.
636
636
637
637
### WS_NO_UTF_8_VALIDATE
638
638
639
- When set to a non empty value, prevents the optional ` utf-8-validate ` dependency
639
+ When set to a non- empty value, prevents the optional ` utf-8-validate ` dependency
640
640
from being required.
641
641
642
642
## Error codes
0 commit comments