예제 #1
0
        /// <summary>
        /// Login by browser auth
        /// </summary>
        /// <returns>Task</returns>
        static async UniTask _Login(LoginCallbackInfo authRes)
        {
            var auth = EOS.auth;
            var con  = EOS.connect;

            var token = auth.CopyUserAuthToken(authRes.LocalUserId);

            if (token == null)
            {
                return;
            }

            var conRes = await con.Login(token.AccessToken, Epic.OnlineServices.Connect.ExternalCredentialType.Epic);

            if (conRes == null)
            {
                return;
            }

            SaveDataUtils.SaveString(Defines.KEY_REFRESH_TOKEN, token.RefreshToken);
            var playerId = conRes.LocalUserId;

            Ctrl.GeneratePlayer(playerId);

            // Set request callback
            _ins._SetRequestCallback();

            await _ins._JoinLobby();
        }
        /// <summary>
        /// 非同期 Login
        /// </summary>
        /// <param name="type">ログイン種別</param>
        /// <param name="id">ID</param>
        /// <param name="token">トークン</param>
        /// <returns>タスク</returns>
        public static async UniTask <LoginCallbackInfo> Login(this ConnectInterface conn, string token, ExternalCredentialType type)
        {
            var op = new LoginOptions
            {
                Credentials = new Credentials
                {
                    Token = token,
                    Type  = type,
                },
            };
            LoginCallbackInfo info = null;

            conn.Login(op, null, e =>
            {
                info = e;
            });

            while (info == null)
            {
                await UniTask.NextFrame();
            }

            if (info.ResultCode == Result.Success)
            {
                return(info);
            }
            Debug.LogError($"error {DebugTools.GetClassMethodName()}:{info.ResultCode}");
            return(null);
        }
        /// <summary>
        /// 非同期 Login
        /// </summary>
        /// <param name="auth">AuthInterface</param>
        /// <param name="type">ログイン種別</param>
        /// <param name="id">ID</param>
        /// <param name="token">トークン</param>
        /// <returns>タスク</returns>
        public static async UniTask <LoginCallbackInfo> Login(this AuthInterface auth, LoginCredentialType type, string id, string token)
        {
            var op = new LoginOptions();

            op.Credentials = new Credentials
            {
                Type  = type,
                Id    = id,
                Token = token,
            };

            LoginCallbackInfo info = null;

            auth.Login(op, null, e =>
            {
                info = e;
            });

            while (info == null)
            {
                await UniTask.NextFrame();
            }

            if (info.ResultCode == Result.Success)
            {
                return(info);
            }
            Debug.LogError($"error {DebugTools.GetClassMethodName()}:{info.ResultCode}");
            return(null);
        }
예제 #4
0
        /// <summary>
        /// Login by browser auth
        /// </summary>
        /// <returns>Task</returns>
        public static async UniTask LoginAuth()
        {
            var auth = EOS.auth;

            var refreshToken          = SaveDataUtils.GetString(Defines.KEY_REFRESH_TOKEN);
            LoginCallbackInfo authRes = null;

            if (refreshToken.NotEmpty())
            {
                authRes = await auth.Login(LoginCredentialType.RefreshToken, string.Empty, refreshToken);
            }

            if (authRes == null)
            {
                authRes = await auth.Login(LoginCredentialType.AccountPortal, string.Empty, string.Empty);

                if (authRes == null)
                {
                    return;
                }
            }

            await _Login(authRes);
        }