File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -20,15 +20,13 @@ const server = http.createServer((_request, response) => {
20
20
wss . on ( 'connection' , setupWSConnection )
21
21
22
22
server . on ( 'upgrade' , ( request , socket , head ) => {
23
- // You may check auth of request here..
23
+ // You may check auth of request here.. Call `wss.HandleUpgrade` *after* you
24
+ // checked whether the client has access (e.g. by checking cookies, or url
25
+ // parameters).
24
26
// See https://github.com/websockets/ws#client-authentication
25
- /**
26
- * @param {any } ws
27
- */
28
- const handleAuth = ws => {
27
+ wss . handleUpgrade ( request , socket , head , /** @param {any } ws */ ws => {
29
28
wss . emit ( 'connection' , ws , request )
30
- }
31
- wss . handleUpgrade ( request , socket , head , handleAuth )
29
+ } )
32
30
} )
33
31
34
32
server . listen ( port , host , ( ) => {
You can’t perform that action at this time.
0 commit comments