You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improvements to Unified Friends List Guide (#7495)
* Fix some small C++ syntax inconsistencies.
* Introduce and explain `UserHandle`, and user data retrieval
* Reorder into what I think is a better learning order.
If we build and run our application, we should now see a list of friends separated into three categories: `Online-GameTitle`, `Online-Elsewhere`, and `Offline`.
211
218
219
+
## Step 3: Monitor Changes to Users
220
+
221
+
To monitor for user changes, we're going using the [`Client::SetUserUpdatedCallback`] function.
222
+
223
+
This callback will be triggered whenever a user's info is updated, such as name or presence changes (when they go online, offline, or start playing your game).
Now your friends list will automatically update when the presence of a friend changes, such as when they go online, offline or start playing your game.
233
+
234
+
:::info
235
+
The automatic updates of the [`UserHandle`] object to the latest the user information should be sufficient for
236
+
retrieving the most up-to-date user information.
237
+
[`Client::SetUserUpdatedCallback`] may be more useful to identify times when you wish to re-sort your
238
+
user list, or similar operations.
239
+
:::
212
240
---
213
241
214
-
## Step 3: Monitor Changes in Relationships
242
+
## Step 4: Monitor Changes in Relationships
215
243
216
-
Let's setup two callbacks to handle relationship updates.
244
+
Let us setup two callbacks to handle relationship updates.
245
+
246
+
:::warn
247
+
These examples rebuild the friends list from scratch every time a relationship changes. For performance reasons, we
248
+
recommend maintaining a collection of [`UserHandle`] objects and adding and removing them appropriately.
249
+
:::
217
250
218
251
### Relationship Created Callback
219
252
220
253
This can happen when a user sends or accepts a friend invite, or blocks a user.
Now your friends list will automatically update when relationships change, such as when you add a new friend, accept a friend request, or block a user.
241
278
242
-
:::warn
243
-
Note: Our example will rebuild the friends list from scratch every time a relationship changes. For performance reasons, you will want to update only the changed relationships.
244
-
:::
245
-
246
-
## Step 4: Monitor Changes to Users
247
-
248
-
To monitor for user changes, we're going using the [`Client::SetUserUpdatedCallback`] function.
249
-
250
-
This callback will be triggered whenever a user's info is updated, such as name or presence changes (when they go online, offline, or start playing your game).
Now your friends list will automatically update when the presence of a friend changes, such as when they go online, offline or start playing your game.
260
-
261
-
:::warn
262
-
Note: Our example will rebuild the friends list from scratch every time a relationship changes. For performance reasons, you will want to update only the user or relationship that changed.
263
-
:::
264
-
265
279
---
266
280
267
281
## Next Steps
@@ -292,4 +306,5 @@ Now that you have a unified friends list, you can build on your social features
0 commit comments