Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

'disconnect' event not exposed. #1243

Closed
tregoning opened this issue Mar 10, 2019 · 2 comments · Fixed by #1355
Closed

'disconnect' event not exposed. #1243

tregoning opened this issue Mar 10, 2019 · 2 comments · Fixed by #1355

Comments

@tregoning
Copy link

Looks like the 'disconnect' event not exposed. is this by design?

How can I detect on the server when a user has disconnected? (either via pingTimeout or explicitly calling disconnect() on the client socket?

Steps to reproduce

app.configure(socketio());
app.on('connection', () => {console.log('connected');});
app.on('disconnect', () => {console.log('disconnected');});

The disconnect callback is never called, after user disconnects.

Expected behavior

console gets 'connected' and eventually 'disconnected' after the user has disconnected and heartbeat expires, or he/she calls disconnect() directly from the client.

Actual behavior

console gets 'connected' but never 'disconnect'

@daffl
Copy link
Member

daffl commented Mar 10, 2019

This will be added in the next version. For now, the disconnect event on the Socket.io socket can be used:

app.configure(socketio(function(io) {
  io.on('connection', function(socket) {
    socket.on('disconnect', () => {
      // Do something here
      // socket.feathers is the `connection` object
    });
  });

@tregoning
Copy link
Author

Great news, thanks for the super quick reply and for all the effort you have put into this project + open-source, support, etc. Outstanding really appreciate it👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants