HardAtWork
08/22/2021, 7:38 PMMallissin
08/22/2021, 7:41 PMMallissin
08/22/2021, 7:42 PMMallissin
08/22/2021, 7:43 PMErwin
08/23/2021, 5:09 AMraRaRa
08/23/2021, 9:38 AMraRaRa
08/23/2021, 9:39 AMErwin
08/23/2021, 10:31 AMraRaRa
08/23/2021, 10:42 AMmz
08/23/2021, 11:15 AMItsWendell
08/23/2021, 11:19 AMmz
08/23/2021, 11:21 AMItsWendell
08/23/2021, 11:22 AMItsWendell
08/23/2021, 11:22 AMItsWendell
08/23/2021, 11:24 AMts
const res = await chatroomStub.fetch(
`http://chatroom/messageSend`,
{
method: 'GET',
headers: headers,
},
)
if (!res.webSocket) {
throw new Error('No websockets found.')
}
res.webSocket.accept();
ItsWendell
08/23/2021, 11:25 AM.accept
is necessary here, but this works now (this is script from the Worker)ItsWendell
08/23/2021, 11:27 AMItsWendell
08/23/2021, 11:27 AMts
// Start websocket server, send client back.
const [client, server]: WebSocket[] = Object.values(
new WebSocketPair(),
)
server.accept()
// Do events on server here.
return new Response(null, {
webSocket: client,
status: 101,
});
mz
08/23/2021, 11:34 AMItsWendell
08/23/2021, 11:37 AMItsWendell
08/23/2021, 11:40 AMmz
08/23/2021, 11:41 AMmz
08/23/2021, 11:42 AM{
"webSocket": null,
"url": "wss://abcdefghi.lmnopqrst.workers.dev/webSocket/createSocket",
"redirected": false,
"ok": false,
"headers": {},
"statusText": "Not Found",
"status": 404,
"bodyUsed": false,
"body": {
"locked": false
}
}
mz
08/23/2021, 11:43 AMItsWendell
08/23/2021, 11:43 AMItsWendell
08/23/2021, 11:44 AMnew Response("OK")
it works?mz
08/23/2021, 11:44 AMmz
08/23/2021, 11:45 AM