update
This commit is contained in:
parent
7edbd8c3cb
commit
af5c36d03a
@ -20,15 +20,13 @@ const server = http.createServer((_request, response) => {
|
|||||||
wss.on('connection', setupWSConnection)
|
wss.on('connection', setupWSConnection)
|
||||||
|
|
||||||
server.on('upgrade', (request, socket, head) => {
|
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
|
// See https://github.com/websockets/ws#client-authentication
|
||||||
/**
|
wss.handleUpgrade(request, socket, head, /** @param {any} ws */ ws => {
|
||||||
* @param {any} ws
|
|
||||||
*/
|
|
||||||
const handleAuth = ws => {
|
|
||||||
wss.emit('connection', ws, request)
|
wss.emit('connection', ws, request)
|
||||||
}
|
})
|
||||||
wss.handleUpgrade(request, socket, head, handleAuth)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
server.listen(port, host, () => {
|
server.listen(port, host, () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user