diff options
| author | Egor Tensin <egor@tensin.name> | 2026-02-28 21:59:12 +0100 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-02-28 22:19:57 +0100 |
| commit | 9611c248995ad3bacda1d0a93d0b5e1e6605d162 (patch) | |
| tree | eb3ae35b426e9d72e7cb34e8e9cc0453745a8e17 /node_modules/undici/docs/api/WebSocket.md | |
| parent | DEVELOPMENT.md: expand on sources (diff) | |
| download | cleanup-path-9611c248995ad3bacda1d0a93d0b5e1e6605d162.tar.gz cleanup-path-9611c248995ad3bacda1d0a93d0b5e1e6605d162.zip | |
upgrade actions/core to version 2
Diffstat (limited to 'node_modules/undici/docs/api/WebSocket.md')
| -rw-r--r-- | node_modules/undici/docs/api/WebSocket.md | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/node_modules/undici/docs/api/WebSocket.md b/node_modules/undici/docs/api/WebSocket.md deleted file mode 100644 index 9d374f4..0000000 --- a/node_modules/undici/docs/api/WebSocket.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: WebSocket - -> ⚠️ Warning: the WebSocket API is experimental. - -Extends: [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) - -The WebSocket object provides a way to manage a WebSocket connection to a server, allowing bidirectional communication. The API follows the [WebSocket spec](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) and [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455). - -## `new WebSocket(url[, protocol])` - -Arguments: - -* **url** `URL | string` - The url's protocol *must* be `ws` or `wss`. -* **protocol** `string | string[] | WebSocketInit` (optional) - Subprotocol(s) to request the server use, or a [`Dispatcher`](./Dispatcher.md). - -### Example: - -This example will not work in browsers or other platforms that don't allow passing an object. - -```mjs -import { WebSocket, ProxyAgent } from 'undici' - -const proxyAgent = new ProxyAgent('my.proxy.server') - -const ws = new WebSocket('wss://echo.websocket.events', { - dispatcher: proxyAgent, - protocols: ['echo', 'chat'] -}) -``` - -If you do not need a custom Dispatcher, it's recommended to use the following pattern: - -```mjs -import { WebSocket } from 'undici' - -const ws = new WebSocket('wss://echo.websocket.events', ['echo', 'chat']) -``` - -## Read More - -- [MDN - WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) -- [The WebSocket Specification](https://www.rfc-editor.org/rfc/rfc6455) -- [The WHATWG WebSocket Specification](https://websockets.spec.whatwg.org/) |
