* @see https://websockets.spec.whatwg.org/#dom-websocket-close * @param {number|undefined} code * @param {string|undefined} reason
(code = undefined, reason = undefined)
| 200 | * @param {string|undefined} reason |
| 201 | */ |
| 202 | close (code = undefined, reason = undefined) { |
| 203 | webidl.brandCheck(this, WebSocket) |
| 204 | |
| 205 | const prefix = 'WebSocket.close' |
| 206 | |
| 207 | if (code !== undefined) { |
| 208 | code = webidl.converters['unsigned short'](code, prefix, 'code', webidl.attributes.Clamp) |
| 209 | } |
| 210 | |
| 211 | if (reason !== undefined) { |
| 212 | reason = webidl.converters.USVString(reason) |
| 213 | } |
| 214 | |
| 215 | // 1. If code is the special value "missing", then set code to null. |
| 216 | code ??= null |
| 217 | |
| 218 | // 2. If reason is the special value "missing", then set reason to the empty string. |
| 219 | reason ??= '' |
| 220 | |
| 221 | // 3. Close the WebSocket with this, code, and reason. |
| 222 | closeWebSocketConnection(this.#handler, code, reason, true) |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * @see https://websockets.spec.whatwg.org/#dom-websocket-send |
nothing calls this directly
no test coverage detected