- Creating a simple API to call.
- Creating up-to-date information by using the Real-Time Activity (RTA) service in the background.
- Developers can call the Social Manager API synchronously without any extra strain on the service.
Features
Social Manager provides the following features.- Simplified social API
- Up-to-date social graph
- Control over the verbosity of information displayed
- Reduced number of calls to XBOX services
- This directly correlates to overall latency reduction in data acquisition
- Thread-safe
- Efficiently keeps data up to date
Core concepts
Social graph: A social graph is created for a local user on the device. This creates a structure that keeps information about all of a user’s friends up to date.On Windows, there can be only one local user.
- Filter groups: A filter group takes a local (calling) user’s social graph and returns a consistently fresh set of users based on specified filter parameters.
- List groups: A list group takes a list of users and returns a consistently fresh view of those users. These users can be outside a user’s friends list.
API overview
You will most frequently use the following key APIs.Adding local users to Social Manager
- Flat C API function: XblSocialManagerAddLocalUser
XBOX social user group
- Flat C API function: XblSocialManagerAddLocalUser
XblSocialManager prefix documentation.
Usage
Creating a social user group from filters
In this scenario, you want a list of users from a filter, such as a list of a user’s Friends or the subset of friends that a user has tagged as favorite. Flat C API- XblPresenceFilter
- XblRelationshipFilter
- XblSocialManagerAddLocalUser
- XblSocialManagerCreateSocialUserGroupFromFilters
- XblSocialManagerDoWork
- XblSocialManagerEvent
Events returned
Local user added: Triggers when loading of a user’s social graph is complete. Indicates if any errors occurred during initialization.- Flat C API: XblSocialManagerEventType
::LocalUserAdded
- Flat C API: XblSocialManagerEventType
::SocialUserGroupLoaded
- Flat C API: XblSocialManagerEventType
::UsersAddedToSocialGraph
- XblSocialManagerEventType (flat C API)
Additional details
Flat C API The previous example shows how to initialize Social Manager for a user, create a social user group for that user, and keep it up to date. The filtering options are the XblPresenceFilter and XblRelationshipFilter enums. In the game loop, the XblSocialManagerDoWork function updates all created views with the latest snapshot of the users in that group. The users in the view can be obtained by calling the XblSocialManagerUserGroupGetUsers function. It returns anXblSocialManagerUserPtrArray, an array of XblSocialManagerUser objects owned by XSAPI.
XblSocialManagerUser contains the social information such as gamertag, gamerpic, and URI.
Create and update a social user group from list
In this scenario, you want the social information of a list of users such as users in a multiplayer session. Flat C API- XblSocialManagerAddLocalUser
- XblSocialManagerCreateSocialUserGroupFromList
- XblSocialManagerDoWork
- XblSocialManagerEvent
Events returned
XblSocialManagerEventType::LocalUserAdded. Triggers when loading of user’s social graph is complete. Indicates if any errors occurred during initialization.
XblSocialManagerEventType::SocialUserGroupLoaded. Triggers when a social user group has been created, and the tracked users have been added to the social graph.
XblSocialManagerEventType::UsersAddedToSocialGraph. Triggers when users are loaded in.
Updating social user group from list
You can also change the list of tracked users in the social user group by calling XblSocialManagerUpdateSocialUserGroup. Flat C APIEvents returned
Social user group updated: Triggers when the social user group update is complete.- C++:
social_user_group_updated - C: XblSocialManagerEventType::SocialUserGroupUpdated
- C++:
users_added_to_social_graph - C: XblSocialManagerEventType::UsersAddedToSocialGraph
- C: XblSocialManagerEventType::UsersRemovedFromSocialGraph
Using Social Manager events
Social Manager tells you what happened, in the form of events. You can use those events to update your UI or perform other logic. Flat C APIEvents returned
XblSocialManagerEventType::LocalUserAdded. Triggers when the loading of a user’s social graph is complete. Indicates if any errors occurred during initialization.
XblSocialManagerEventType::SocialUserGroupLoaded. Triggers when a social user group has been created.
XblSocialManagerEventType::UsersAddedToSocialGraph. Triggers when users are loaded in.
XblSocialManagerEventType::UsersRemovedFromSocialGraph. Triggers when a user is removed from the social graph.
XblSocialManagerEventType::PresenceChanged. Triggers when the presence of a user in the social graph changes.
XblSocialManagerEventType::ProfilesChanged. Triggers when the profile of a user in the social graph changes.
XblSocialManagerEventType::SocialRelationshipsChanged. Triggers when the relationship between the local user and another user in the social graph changes.
XblSocialManagerEventType::SocialUserGroupUpdated. Triggers when an update to a social user group is complete.
Additional details
This example shows some of the additional control that’s offered by Social Manager. Rather than relying on the social user group filters to provide a fresh user list during the game loop, the social graph is initialized outside the game loop. The title then relies on the events that are returned by the XblSocialManagerDoWork function. Events is a list of XblSocialManagerEvent. Each XblSocialManagerEvent contains a change to the social graph that occurred during the last frame. For example, XblSocialManagerEventType::ProfilesChanged and XblSocialManagerEventType::UsersAddedToSocialGraph.
For more information, see the XblSocialManagerEvent API documentation.
