XUserAddAsync
Asynchronously adds a user to a game session.Syntax
Parameters
options _In_Type: XUserAddOptions Options for adding a user to a game session. async _Inout_
Type: XAsyncBlock* An XAsyncBlock for polling for the call’s status and retrieving call results.
Return value
Type: HRESULT HRESULT success or error code. For a list of error codes, see Error Codes.Remarks
XUserAddAsync starts an asynchronous operation to add a user to the game. Use XUserAddResult to retrieve the results of the operation. XUserAddAsync always shows an Account Picker UI unless either XUserAddOptions::AddDefaultUserSilently or XUserAddOptions::AddDefaultUserAllowingUI is passed to the options parameter. If you use XUserAddOptions::AddDefaultUserSilently, XUserAddAsync does not show a UI. There are some considerations with this function when using the simplified user model (NDA topic):- With simplified user model, developers should ensure that options is set to XUserAddOptions::AddDefaultUserSilently:
- On console, loose-deployed games using the simplified user model will not be allowed to launch unless there is already a default user signed in.
- On PC, loose-deployed games using the simpfied user model can be launched without a user; however, when the game calls XUserAddAsync, if nobody is signed in, the game will get terminated and the PC Bootstrapper will get launched to help sign-in a user. Subsequent launches will work just fine so long as the user is fully signed into XBOX Live.
- If you call this repeatedly, and we know the default user who launched the game, it will return that same user.
- If the previously known default user has signed out, and there is only one user signed into the device, it will mark that user as the new “default” user and return that.
- If the previously known default user has signed out, and there are multiple users signed into the device, it will return E_GAMEUSER_NO_DEFAULT_USER.
- If you call this repeatedly, and we know the default user who launched the game, it will return that same user.
- If the previously known default user has signed out, and there is only one user signed into the device, it will mark that user as the new “default” user and return that.
- If the user has signed out who initially launched the game, and the number of users is either 0 or more than 1, the system will show UI to get the user and then set that user as the default.
Requirements
Header: XUser.h Library: xgameruntime.lib Supported platforms: Windows, Steam Deck, XBOX One family consoles and XBOX Series consolesConceptual documentation
- Run Microsoft Game Development Kit (GDK) API task
- Asynchronous programming design goals and improvements
- Implement player sign-in in your game
- Intro to Game Chat 2
- Using the Game Chat 2 C++ API
- Implement player sign in
