feathers-chat icon indicating copy to clipboard operation
feathers-chat copied to clipboard

Mark users as online or offline.

Open ekryski opened this issue 10 years ago • 7 comments

Currently we need to hook into the socket to mark as user online when:

  • They connect & authenticate

and offline when:

  • When the socket disconnects
  • When they logout
  • When they haven't been authenticated or done anything for a while (ie. token expires maybe?)

ekryski avatar Mar 19 '16 20:03 ekryski

Is there a way, when they authenticate, to get the socket id on which it has happened ? This way, we could have an array of socket id on which the user is currently connected (and if the array is empty, then the user isn't connected anywhere).

ghost avatar May 19 '16 12:05 ghost

Marshall mentioned that feather-authenticate v1 now has auth.on('create', ...) and auth.on('remove', ...)?

eddyystop avatar Jan 09 '17 01:01 eddyystop

It has app.on('login') and app.on('logout') (which emits some additional information like the connection and request/response object if available).

daffl avatar Jan 09 '17 01:01 daffl

@daffl app.on('logout') seems to not be generating for rest provider. app.on('login') seems to be generating for both socket io and rest

subodhpareek18 avatar Oct 23 '17 12:10 subodhpareek18

For REST the user has to explicitly call app.logout() since there is no other way to tell. In Socket.io the logout event will also be sent on socket disconnection.

daffl avatar Oct 23 '17 15:10 daffl

Could someone please paste the code needed to hack into socket.io for listing all user connections?

boustanihani avatar Apr 23 '18 11:04 boustanihani

The best (and not so hacky) way to get all connections is to combine all event channels and list those connections:

app.channel(app.channels).connections.forEach(connection => {});

daffl avatar Apr 23 '18 16:04 daffl