List all users
GetUsers() returns a paginated list of all users with their metadata.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Chat->GetUsersAsync(OnGetUsersResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatGetUsersResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatGetUsersResult Result = Chat->GetUsers();
Requires App Context
Enable App Context in the Admin Portal to store user data. If using Access Manager, uncheck Disallow Get All User Metadata in the App Context configuration.
Method signature
1Chat->GetUsers(
2 int Limit = 0,
3 FString Filter = "",
4 FPubnubGetAllSort Sort = FPubnubGetAllSort(),
5 FPubnubPage Page = FPubnubPage()
6);
| Parameter | Description |
|---|---|
LimitType: intDefault: 0 (server default) | Number of objects to return in response. |
FilterType: FStringDefault: "" | Expression used to filter the results. Returns only those users whose properties satisfy the given expression. The filter language is defined here. |
SortType: FPubnubGetAllSortDefault: n/a | Key-value pair of a property to sort by, and a sort direction. Available options are id, name, and updated. Use asc or desc to specify the sorting direction. By default, the items are sorted by the last updated date. |
PageType: FPubnubPageDefault: n/a | Object used for pagination to define which previous or next result page you want to fetch. |
→ NextType: FStringDefault: n/a | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
→ PrevType: FStringDefault: n/a | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Output
| Parameter | Description |
|---|---|
FPubnubChatGetUsersResultType: struct | Returned object containing Result, Users, Page, and Total. |
→ ResultType: FPubnubChatOperationResult | Operation result with Error (bool) and ErrorMessage (FString). |
→ UsersType: TArray<UPubnubChatUser*> | Array of all matching users. |
→ PageType: FPubnubPage | String that lets you either fetch the next (Next) or previous (Prev) result page. |
→ NextType: FString | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
→ PrevType: FString | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
→ TotalType: int | Total number of User objects matching the request query. |
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Retrieve a paginated list of users asynchronously.
Actor.h
1
Actor.cpp
1
Other examples
Pagination
Get the total number of 25 users and then specify that you want to fetch the results from the next page using a string that was previously returned from the PubNub server.
Actor.h
1
Actor.cpp
1
Archived users
Get all archived users. This request will return all soft-deleted users whose data is still stored in the App Context storage.
Actor.h
1
Actor.cpp
1