DEV Community

Discussion on: How to Build a Real-time Chat App With NodeJS, Socket.IO, and MongoDB

Collapse
 
shriyamadan profile image
Shriya Madan

Heya! Can you tell me how to add a feature for showing "online", once the user is active?
Great work!

Collapse
 
ezesunday profile image
Eze Sunday Eze • Edited

It's not straight forward though. different browsers implement this differently.

But you can do two things, use the offlineOnline browser api here

Ping a website you are sure will always be available such as Google in a http request. You can broadcast same event to other members saying the user is offline. That's it.

Collapse
 
g_mann43 profile image
Gavin

Would you not do presence by holding an array of users on server side and upon connection add the user to the array and broadcast to everyone/room...and on disconnect remove the user from the array and broadcast the disconnection status ?

Collapse
 
shriyamadan profile image
Shriya Madan

chat-with-friends.herokuapp.com/
Here's my chat application. Check it, please :)

Thread Thread
 
ezesunday profile image
Eze Sunday Eze

Went through it. It seems to work really well. Good job.

Do you plan to make something much more bigger with this?

Thread Thread
 
ezesunday profile image
Eze Sunday Eze

Glad to see what you have build so far. Keep it up.

Thread Thread
 
shriyamadan profile image
Shriya Madan

Thank you! :) Yeah, I am looking for ideas to make something better out of it.