PhilipA
03/06/2021, 9:25 PMRobin
03/07/2021, 8:42 PMRobin
03/07/2021, 8:44 PMRobin
03/07/2021, 8:44 PMeidam | SuperSaaS
03/07/2021, 8:48 PMRobin
03/07/2021, 8:49 PMRobin
03/07/2021, 8:50 PMPhilipA
03/07/2021, 11:10 PMkenton
03/08/2021, 6:54 PMfetch()
and set the header Upgrade: websocket
, the system will automatically add the other stuff to perform a WebSocket handshake. If the server fulfills its end of the handshake, then the response object will have a webSocket
member. Call .accept()
on it to indicate you wish to handle it locally, and then you can call send()
and add event handlers like normal.Greg Brimble | Cloudflare Pages
03/08/2021, 7:50 PMPhilipA
03/08/2021, 8:02 PMkenton
03/08/2021, 8:51 PMCeru ©
03/08/2021, 10:55 PMCeru ©
03/08/2021, 10:55 PMCeru ©
03/08/2021, 11:03 PMCeru ©
03/08/2021, 11:28 PMkenton
03/08/2021, 11:29 PMCeru ©
03/08/2021, 11:29 PMCeru ©
03/09/2021, 2:32 AMjs
var url = 'wss://echo.websocket.org'
var resp = await fetch(url, { headers: {'upgrade': 'websocket'} })
// resp.webSocket is null
Ceru ©
03/09/2021, 2:46 AMhttps://nyc3.digitaloceanspaces.com/cerulean/screenshots/2021/03/firefox_wEa6pgpUWe.png▾
ai
03/09/2021, 3:06 AMai
03/09/2021, 3:07 AMai
03/09/2021, 3:13 AMwss
, just ws
.Ceru ©
03/09/2021, 3:13 AMCeru ©
03/09/2021, 3:14 AMCeru ©
03/09/2021, 3:14 AMCeru ©
03/09/2021, 3:14 AMai
03/09/2021, 3:18 AMTo establish a WebSocket connection, given a url, protocols, and client, run these steps:
Let requestURL be a copy of url, with its scheme set to "http", if url’s scheme is "ws", and to "https" otherwise.
Ceru ©
03/09/2021, 3:19 AMCeru ©
03/09/2021, 3:19 AM