You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I read a lot through all the issues and half of the internet but it seams that the disconnect event is not passed through on the server.
In my app I want to track all users that open the page. I also need to know when they leave the page. The only way way I found to know when someone disconnects is by hacking the original io object into the app, like this:
in app.js
app.configure(socketio(io => {
// Registering Socket.io middleware
io.use(function (socket, next) {
// Exposing a request property to services and hooks
socket.feathers.clientId = socket.id;
// Adding the original socket
socket.feathers.io = socket
next();
});
}));
And now I am able to do this in channels.js
app.on('connection', connection => {
// On a new real-time connection, add it to the anonymous channel
app.channel('anonymous').join(connection);
// Keep the clientId around for later
const clientId = connection.clientId
// Do something with the clientId
console.log('connection ', clientId);
// Register the listener for the disconnect event
connection.io.on('disconnect', event => {
console.log('dissssss', event, clientId);
})
});
This seams pretty hacky and I can't believe there is no other way, but I couldn't find it. Please let me know if this is a legitimate way of doing this.
I am using the latest version of feathers.
ps. The solution given here #957 is not working for me, I think because I don\t authenticate the users...
The text was updated successfully, but these errors were encountered:
I read a lot through all the issues and half of the internet but it seams that the disconnect event is not passed through on the server.
In my app I want to track all users that open the page. I also need to know when they leave the page. The only way way I found to know when someone disconnects is by hacking the original io object into the app, like this:
in app.js
And now I am able to do this in channels.js
This seams pretty hacky and I can't believe there is no other way, but I couldn't find it. Please let me know if this is a legitimate way of doing this.
I am using the latest version of feathers.
ps. The solution given here #957 is not working for me, I think because I don\t authenticate the users...
The text was updated successfully, but these errors were encountered: