# Listing online friends

**URL:** <https://forum.heroiclabs.com/t/listing-online-friends/5910>\
**Category:** Runtime Framework\
**Tags:** server-framework, typescript\
**Created:** [January 3, 2025, 4:03pm UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910 "2025-01-03T16:03:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MinatoTW](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MinatoTW](https://forum.heroiclabs.com/u/MinatoTW)\
**Post date:** [January 3, 2025, 4:04pm UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/1 "2025-01-03T16:04:00Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [January 7, 2025, 11:26am UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/2 "2025-01-07T11:26:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MinatoTW](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MinatoTW](https://forum.heroiclabs.com/u/MinatoTW)\
**Post date:** [January 8, 2025, 7:22am UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/3 "2025-01-08T07:22:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MinatoTW](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MinatoTW](https://forum.heroiclabs.com/u/MinatoTW)\
**Post date:** [January 9, 2025, 2:52pm UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/4 "2025-01-09T14:52:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [January 9, 2025, 5:28pm UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/5 "2025-01-09T17:28:59Z")

</div>

Yes you’ll need to set a status for the user to appear online: [Status - Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/concepts/status/#set-a-status)

---

<div class="post-metadata">

**Author:** ![MinatoTW](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MinatoTW](https://forum.heroiclabs.com/u/MinatoTW)\
**Post date:** [January 10, 2025, 2:31am UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/6 "2025-01-10T02:31:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [January 10, 2025, 11:44am UTC](https://forum.heroiclabs.com/t/listing-online-friends/5910/7 "2025-01-10T11:44:56Z")

</div>

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.
