How to get online users by websocket?

Hey, guys.

I have a Chat App, I want Show in chat the other user is online or not.

if the other user isn’t online, I want to show the last active for him

Please help.