Example #1
0
        private bool onSessionStarted(SessionEvents.SessionStartedEvent evt)
        {
            ILocalUser localUser = Service.Get <SessionManager>().LocalUser;

            if (string.IsNullOrEmpty(localUser.RegistrationProfile.Username))
            {
                localUser.RefreshProfile(onProfileUpdated);
            }
            else
            {
                setupSession();
            }
            return(false);
        }
Example #2
0
        public virtual void AddMixSession(ISession mixSession, bool canPrepopulateDisplayName = false)
        {
            if (mixSession == null)
            {
                throw new ArgumentException("Mix Session cannot be null!");
            }
            if (this.mixSession != null)
            {
                clearSession();
            }
            this.mixSession = mixSession;
            accessToken     = mixSession.GuestControllerAccessToken;
            LocalUser       = mixSession.LocalUser;
            localPlayerSwid = LocalUser.Id;
            setLanguage();
            addListeners();
            GameSettings gameSettings = Service.Get <GameSettings>();

            if (!gameSettings.OfflineMode)
            {
                string username = LocalUser.RegistrationProfile.Username;
                if (string.IsNullOrEmpty(username))
                {
                    LocalUser.RefreshProfile(delegate
                    {
                        continueLoginWithOfflineDataCopy();
                    });
                }
                else
                {
                    continueLoginWithOfflineDataCopy();
                }
            }
            else
            {
                eventDispatcher.DispatchEvent(new SessionEvents.SessionStartedEvent(accessToken, localPlayerSwid));
            }
            if (LocalUser.RegistrationProfile.DisplayNameProposedStatus != DisplayNameProposedStatus.None || string.IsNullOrEmpty(LocalUser.RegistrationProfile.Username) || !canPrepopulateDisplayName)
            {
                return;
            }
            LocalUser.ValidateDisplayName(LocalUser.RegistrationProfile.Username, delegate(IValidateDisplayNameResult result)
            {
                if (result.Success)
                {
                    AccountFlowData accountFlowData = Service.Get <MembershipService>().GetAccountFlowData();
                    accountFlowData.PreValidatedDisplayNames.Add(LocalUser.RegistrationProfile.Username);
                }
            });
        }