From 5a12ac371f82415ba37b2465d52ec3bd8412cc69 Mon Sep 17 00:00:00 2001 From: Jiri Spac Date: Sun, 24 Nov 2024 07:06:51 +0100 Subject: [PATCH 1/2] add comments about server/client weirdness --- src/content/docs/workers/examples/websockets.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/content/docs/workers/examples/websockets.mdx b/src/content/docs/workers/examples/websockets.mdx index 65ea602e4e89be..3865a4bc93ba65 100644 --- a/src/content/docs/workers/examples/websockets.mdx +++ b/src/content/docs/workers/examples/websockets.mdx @@ -94,8 +94,8 @@ async function handleRequest(request) { } const webSocketPair = new WebSocketPair(); - const client = webSocketPair[0], - server = webSocketPair[1]; + const client = webSocketPair[0], // server-side WS endpoint in the worker + server = webSocketPair[1]; // this is the remote from whoever connected to your worker-a browser client for example return new Response(null, { status: 101, @@ -118,8 +118,8 @@ async fn fetch(req: HttpRequest, _env: Env, _ctx: Context) -> Result Date: Mon, 30 Dec 2024 15:26:38 +0000 Subject: [PATCH 2/2] structure/grammar fix --- src/content/docs/workers/examples/websockets.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/content/docs/workers/examples/websockets.mdx b/src/content/docs/workers/examples/websockets.mdx index 3865a4bc93ba65..f7a38661126a8d 100644 --- a/src/content/docs/workers/examples/websockets.mdx +++ b/src/content/docs/workers/examples/websockets.mdx @@ -94,8 +94,10 @@ async function handleRequest(request) { } const webSocketPair = new WebSocketPair(); - const client = webSocketPair[0], // server-side WS endpoint in the worker - server = webSocketPair[1]; // this is the remote from whoever connected to your worker-a browser client for example + // This is the server-side WebSocket in the Worker. + const client = webSocketPair[0], + //This is the remote connection. For example, from a browser client. + server = webSocketPair[1]; return new Response(null, { status: 101, @@ -118,8 +120,10 @@ async fn fetch(req: HttpRequest, _env: Env, _ctx: Context) -> Result