Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Mar 26, 2024
1 parent 7edbd8c commit af5c36d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions bin/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ const server = http.createServer((_request, response) => {
wss.on('connection', setupWSConnection)

server.on('upgrade', (request, socket, head) => {
// You may check auth of request here..
// You may check auth of request here.. Call `wss.HandleUpgrade` *after* you
// checked whether the client has access (e.g. by checking cookies, or url
// parameters).
// See https://github.com/websockets/ws#client-authentication
/**
* @param {any} ws
*/
const handleAuth = ws => {
wss.handleUpgrade(request, socket, head, /** @param {any} ws */ ws => {
wss.emit('connection', ws, request)
}
wss.handleUpgrade(request, socket, head, handleAuth)
})
})

server.listen(port, host, () => {
Expand Down

0 comments on commit af5c36d

Please sign in to comment.