/// <summary> /// Signs in a player. Attempts sign in silently first then sign in. /// </summary> /// <param name="playerNumber">The player number</param> /// <param name="playerInfo">The player info of the the player being signed in</param> /// <returns>A Coroutine</returns> private IEnumerator SignInAsync(int playerNumber, XboxLivePlayerInfo playerInfo) { SignInStatus signInStatus = SignInStatus.Success; TaskYieldInstruction <SignInResult> signInSilentlyTask = playerInfo.XboxLiveUser.SignInSilentlyAsync().AsCoroutine(); yield return(signInSilentlyTask); try { signInStatus = signInSilentlyTask.Result.Status; } catch (Exception ex) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogError("Exception occured: " + ex.Message); } } if (signInStatus != SignInStatus.Success) { TaskYieldInstruction <SignInResult> signInTask = playerInfo.XboxLiveUser.SignInAsync().AsCoroutine(); yield return(signInTask); try { signInStatus = signInTask.Result.Status; } catch (Exception ex) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogError("Exception occured: " + ex.Message); } } } try { // Throw any exceptions if needed. if (signInStatus == SignInStatus.Success) { CurrentNumberOfPlayers++; XboxLive.Instance.StatsManager.AddLocalUser(playerInfo.XboxLiveUser); XboxLive.Instance.SocialManager.AddLocalUser(playerInfo.XboxLiveUser, SocialManagerExtraDetailLevel.PreferredColorLevel); this.NotifyAllCallbacks(playerNumber, playerInfo.XboxLiveUser, XboxLiveAuthStatus.Succeeded, null, true); } else { NotifyAllCallbacks(playerNumber, null, XboxLiveAuthStatus.Failed, "Sign In Failed: Player " + playerNumber + " failed. Sign In Status: " + signInStatus); } } catch (Exception ex) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogError("Exception occured: " + ex.Message); } } }
/// <summary> /// Signs in a player. Attempts sign in silently first then sign in. /// </summary> /// <param name="playerNumber">The player number</param> /// <param name="playerInfo">The player info of the the player being signed in</param> /// <returns>A Coroutine</returns> private IEnumerator SignInAsync(int playerNumber, XboxLivePlayerInfo playerInfo) { SignInStatus signInStatus = SignInStatus.Success; TaskYieldInstruction <SignInResult> signInSilentlyTask = playerInfo.XboxLiveUser.SignInSilentlyAsync().AsCoroutine(); yield return(signInSilentlyTask); try { signInStatus = signInSilentlyTask.Result.Status; } catch (Exception ex) { ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.SignInSilentlyFailed, ex); } if (signInStatus != SignInStatus.Success) { TaskYieldInstruction <SignInResult> signInTask = playerInfo.XboxLiveUser.SignInAsync().AsCoroutine(); yield return(signInTask); try { signInStatus = signInTask.Result.Status; } catch (Exception ex) { ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.SignInFailed, ex); } } try { // Throw any exceptions if needed. if (signInStatus == SignInStatus.Success) { CurrentNumberOfPlayers++; XboxLive.Instance.StatsManager.AddLocalUser(playerInfo.XboxLiveUser); XboxLive.Instance.SocialManager.AddLocalUser(playerInfo.XboxLiveUser, SocialManagerExtraDetailLevel.PreferredColorLevel); this.NotifyAllCallbacks(playerNumber, playerInfo.XboxLiveUser, XboxLiveAuthStatus.Succeeded, null, true); } else { this.CurrentPlayers[playerNumber].XboxLiveUser = null; this.CurrentPlayers[playerNumber].XboxLiveContext = null; #if ENABLE_WINMD_SUPPORT this.CurrentPlayers[playerNumber].WindowsUser = null; #endif NotifyAllCallbacks(playerNumber, null, XboxLiveAuthStatus.Failed, "Sign In Failed: Player " + playerNumber + " failed. Sign In Status: " + signInStatus); } } catch (Exception ex) { ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.SignInFailed, ex); } }