diff options
author | 2023-09-08 22:22:28 +0100 | |
---|---|---|
committer | 2023-09-08 14:22:28 -0700 | |
commit | c896792c37574b745f5b2a05e2f7d20aa4cdd9ac (patch) | |
tree | ece462cd7ca572048a08b390001ce15c998f0f7c | |
parent | 088491cb594ffa4a73f92e42e838a20799986a34 (diff) | |
download | bun-c896792c37574b745f5b2a05e2f7d20aa4cdd9ac.tar.gz bun-c896792c37574b745f5b2a05e2f7d20aa4cdd9ac.tar.zst bun-c896792c37574b745f5b2a05e2f7d20aa4cdd9ac.zip |
fix(docs): connect websocket client repeated documentation (#4615)
-rw-r--r-- | docs/api/websockets.md | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/docs/api/websockets.md b/docs/api/websockets.md index defc9e18c..e704419bb 100644 --- a/docs/api/websockets.md +++ b/docs/api/websockets.md @@ -12,18 +12,6 @@ Internally Bun's WebSocket implementation is built on [uWebSockets](https://github.com/uNetworking/uWebSockets). {% /callout %} -## Connect to a WebSocket server - -{% callout %} -**🚧** — The `WebSocket` client still does not pass the full [Autobahn test suite](https://github.com/crossbario/autobahn-testsuite) and should not be considered ready for production. -{% /callout %} - -Bun implements the `WebSocket` class. To create a WebSocket client that connects to a `ws://` or `wss://` server, create an instance of `WebSocket`, as you would in the browser. - -```ts -const socket = new WebSocket("ws://localhost:3000"); -``` - ## Start a WebSocket server Below is a simple WebSocket server built with `Bun.serve`, in which all incoming requests are [upgraded](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) to WebSocket connections in the `fetch` handler. The socket handlers are declared in the `websocket` parameter. @@ -248,7 +236,11 @@ This gives you better control over backpressure in your server. ## Connect to a `Websocket` server -To connect to an external socket server, either from a browser or from Bun, create an instance of `WebSocket` with the constructor. +{% callout %} +**🚧** — The `WebSocket` client still does not pass the full [Autobahn test suite](https://github.com/crossbario/autobahn-testsuite) and should not be considered ready for production. +{% /callout %} + +Bun implements the `WebSocket` class. To create a WebSocket client that connects to a `ws://` or `wss://` server, create an instance of `WebSocket`, as you would in the browser. ```ts const socket = new WebSocket("ws://localhost:3000"); |