How can I access the passport login for the current session when someone opens a connection to WebSocket?
I found a nice express-ws project that seems to be perfectly executed
app.ws('/', function(ws, req) { ws.on('message', function(msg) { console.log('express-ws --- ', msg); }); console.log('socket', req.user);
But how do I get the same information with a simple connection to Websocket?
var WebSocketServer = require('ws').Server, wss = new WebSocketServer({ port: 3001 }); wss.on('connection', function(socket){ //Where is the current user???? console.log('connection'); socket.on('message', function(message){ console.log('message received', message); }); });
(this second connection works very well, but for my life I canβt find a way to get the registered information from my passport)
source share