Hello,
In our game we load a list of the users friends when they login and then show online ones at the top. When I use friendsList
there’s an online parameter in the user object but it’s not populated.
How do I go about this? It seems I can follow all my friends to get a list of presences but I’m not sure about the performance impact of doing that over every login specially with a large number of friends. I’m using a global stream to detect presence and update my online/offline friends while playing the game, so I don’t need the follow feature.
Thanks!
Hello @MinatoTW,
When you say that the online parameter is not populated, you mean that the corresponding users are connected via socket but the field shows as offline? Is this for the JS runtime function or another?
The follow feature uses streams under-the-hood, a global stream can make sense for some specific use-cases but if you’re only using it for online/offline status updates I think you can revert back to just using follow/unfollow directly, there won’t be a performance penalty.
Best.
Hello,
Yes, both the user’s are connected via socket but the friendList API still says online: false
for the friend.
"Friends: {\"friends\":[{\"state\":0,\"updateTime\":1736320756,\"user\":{\"avatarUrl\":\"\",\"timezone\":\"\",\"username\":\"pogger\",\"displayName\":\"pogger\",\"edgeCount\":0,\"metadata\":{},\"userId\":\"09d32567-f038-45d7-b501-3b2c7cf9acbe\",\"location\":\"\",\"online\":false,\"createTime\":1736254754,\"updateTime\":1736320755,\"langTag\":\"en\"}}]}
This is via the JS runtime. As for the global stream, I plan to use it for a global chat as well, so I guess it’s fine to continue using that to get presences as well?
Thanks
This seems to be the case with the usersGetFriendStatus
API as well, online is set to false. Does the user need to explicitly mark themselves as online?
Yes you’ll need to set a status for the user to appear online: Status - Heroic Labs Documentation
Thanks, As I understand from the docs this will say online even if the user abruptly disconnects etc right? Is there no way to know their true online status?
If the socket disconnects (either gracefully or not) the status should update to offline accordingly - however if it’s not a graceful disconnect, detection may take some time depending on the OS where the server is running, as well as some socket configuration param values.