So I have this problem using express with socket.io. I think it is pretty self explanitory; I simply need to get the session and request parameter data to socket.io. This cannot be done on the client side as some rooms are going to be private. Any solutions?
io.sockets.on('connection', function (socket) {
socket.join(ROOM ID)
socket.on('send message', function(data) {
NEED USER ID STORED IN session.user
}
})
app.get('/:roomid', function (req, res) {
//req.session.user = THE USER ID
//req.params.roomid = THE ROOM ID
})
Socket.IO 0.7.7~ introduces a new property on the socket called handshake
this is the data that we gather when the client does it's initial handshake request. It contains the headers, ip and some other stuff.
This wiki https://github.com/LearnBoost/socket.io/wiki/Authorizing touches the subject lightly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With