Allow configuring server port
This commit is contained in:
parent
6abf787d9c
commit
bc9ef895ad
1 changed files with 51 additions and 47 deletions
|
|
@ -9,12 +9,15 @@ type Message =
|
||||||
|
|
||||||
const clients: Map<WebsocketData['clientId'], WebSocket> = new Map()
|
const clients: Map<WebsocketData['clientId'], WebSocket> = new Map()
|
||||||
|
|
||||||
const _server = Deno.serve((req) => {
|
const _server = Deno.serve({
|
||||||
|
port: Number.parseInt(Deno.env.get('PORT') || '8000', 10),
|
||||||
|
handler: (req) => {
|
||||||
if (req.headers.get("upgrade") !== "websocket") {
|
if (req.headers.get("upgrade") !== "websocket") {
|
||||||
return new Response(null, { status: 501 })
|
return new Response(null, { status: 501 })
|
||||||
}
|
}
|
||||||
|
|
||||||
const { socket, response } = Deno.upgradeWebSocket(req)
|
const { socket, response } = Deno.upgradeWebSocket(req)
|
||||||
|
|
||||||
// TODO Allow creating private ponds
|
// TODO Allow creating private ponds
|
||||||
const clientId = crypto.randomUUID()
|
const clientId = crypto.randomUUID()
|
||||||
console.log('generated clientId', clientId)
|
console.log('generated clientId', clientId)
|
||||||
|
|
@ -65,4 +68,5 @@ const _server = Deno.serve((req) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue