How to handle WebSockets?
omar2205 opened this issue · comments
I have this endpoint:
// routes/h.ts
export function GET(req: Request) {
const { socket, response } = Deno.upgradeWebSocket(req)
socket.onopen = () => {
console.log('WS OPEN')
socket.send('Hello')
}
socket.onmessage = (e) => {
console.log('msg', e.data)
socket.send(new Date().toJSON())
}
return response
}
When I try to call this, like: let ws = new WebSocket('ws://localhost:8000/h')
, I don't receive anything, and no 'WS OPEN' gets logged.
there is a bug about it, I will fix it ASAP