/// <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);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loginCallbackInfo"></param>
        private void OnConnectInterfaceLogin(OnlineServices.Connect.LoginCallbackInfo loginCallbackInfo)
        {
            if (loginCallbackInfo.ResultCode == Result.Success)
            {
                if (_enableDebugLogs)
                {
                    DebugLogger.RegularDebugLog("[EpicManager] - Connect Interface Login succeeded");
                }

                Result result = loginCallbackInfo.LocalUserId.ToString(out string productIdString);

                if (Result.Success == result)
                {
                    if (_enableDebugLogs)
                    {
                        DebugLogger.RegularDebugLog("[EpicManager] - User Product ID:" + productIdString);
                    }

                    AccountId = new EpicUser(AccountId.EpicAccountId, loginCallbackInfo.LocalUserId);

                    OnLoggedIn?.Invoke();
                }
            }
            else
            {
                if (_enableDebugLogs)
                {
                    DebugLogger.RegularDebugLog("[EpicManager] - Login returned " + loginCallbackInfo.ResultCode);
                }

                ConnectInterface.CreateUser(
                    new CreateUserOptions {
                    ContinuanceToken = loginCallbackInfo.ContinuanceToken
                }, null, cb =>
                {
                    if (cb.ResultCode != Result.Success)
                    {
                        if (_enableDebugLogs)
                        {
                            DebugLogger.RegularDebugLog(
                                $"[EpicManager] - User creation failed. Result: {cb.ResultCode}");
                        }
                        return;
                    }

                    AccountId = new EpicUser(AccountId.EpicAccountId, loginCallbackInfo.LocalUserId);

                    ConnectInterfaceLogin();
                });
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        private void ConnectInterfaceLogin()
        {
            var loginOptions = new OnlineServices.Connect.LoginOptions();

            switch (_connectInterfaceCredentialType)
            {
            case ExternalCredentialType.Epic:
            {
                Result result = AuthInterface.CopyUserAuthToken(new CopyUserAuthTokenOptions(), AccountId.EpicAccountId,
                                                                out Token token);

                if (result == Result.Success)
                {
                    _connectInterfaceCredentialToken = token.AccessToken;
                }
                else
                {
                    if (_enableDebugLogs)
                    {
                        DebugLogger.RegularDebugLog("[EpicManager] - Failed to retrieve User Auth Token");
                    }
                }

                break;
            }

            case ExternalCredentialType.DeviceidAccessToken:
                loginOptions.UserLoginInfo = new UserLoginInfo {
                    DisplayName = displayName
                };
                break;
            }

            loginOptions.Credentials =
                new OnlineServices.Connect.Credentials
            {
                Type = _connectInterfaceCredentialType, Token = _connectInterfaceCredentialToken
            };

            ConnectInterface.Login(loginOptions, null, OnConnectInterfaceLogin);
        }
示例#4
0
    /// <summary>
    /// Initialize the interface.
    /// </summary>
    private void Start()
    {
        //keep track of sub-interfaces
        MainInterface thisScript = GetComponent <MainInterface>();

        dragInterface = transform.GetChild(0).gameObject.GetComponent <DragInterface>();
        dragInterface.mainInterface    = thisScript;
        connectInterface               = transform.GetChild(1).gameObject.GetComponent <ConnectInterface>();
        connectInterface.mainInterface = thisScript;
        pairInterface = transform.GetChild(2).gameObject.GetComponent <PairInterface>();
        pairInterface.mainInterface = thisScript;

        gloves = new Dictionary <int, HandController>();

        //add new gloves to the library
        GenerateGlove("00001001-7374-7265-7563-6873656e7365");
        GenerateGlove("00601001-7374-7265-7563-6873656e7365");
        GenerateGlove("00000501-7374-7265-7563-6873656e7365");
        GenerateGlove("00600501-7374-7265-7563-6873656e7365");

        //add corresponding connection panels for the library's gloves
        Populate();
    }
示例#5
0
        /// <summary>
        ///     Initialize epic sdk.
        /// </summary>
        /// <returns>Returns back whether or not the engine initialized correctly.</returns>
        private void Initialize()
        {
            if (_enableDebugLogs)
            {
                DebugLogger.RegularDebugLog("[EpicManager] - Initializing epic services.");
            }

            InitializeOptions initializeOptions =
                new InitializeOptions {
                ProductName = _options.ProductName, ProductVersion = _options.ProductVersion
            };

            Result initializeResult = PlatformInterface.Initialize(initializeOptions);

            // This code is called each time the game is run in the editor, so we catch the case where the SDK has already been initialized in the editor.
            bool isAlreadyConfiguredInEditor = Application.isEditor && initializeResult == Result.AlreadyConfigured;

            if (initializeResult != Result.Success && !isAlreadyConfiguredInEditor)
            {
                throw new Exception("[EpicManager] - Failed to initialize platform: " + initializeResult);
            }

            if (_enableDebugLogs)
            {
                LoggingInterface.SetLogLevel(LogCategory.AllCategories, _epicLoggingLevel);
                LoggingInterface.SetCallback(message => DebugLogger.EpicDebugLog(message));
            }

            ClientCredentials clientCredentials =
                new ClientCredentials {
                ClientId = _options.ClientId, ClientSecret = _options.ClientSecret
            };

            OnlineServices.Platform.Options options =
                new OnlineServices.Platform.Options
            {
                ProductId                = _options.ProductId,
                SandboxId                = _options.SandboxId,
                ClientCredentials        = clientCredentials,
                IsServer                 = false,
                DeploymentId             = _options.DeploymentId,
                TickBudgetInMilliseconds = (uint)_tickTime * 1000
            };

            Platform = PlatformInterface.Create(options);

            if (Platform != null)
            {
                if (_enableDebugLogs)
                {
                    DebugLogger.RegularDebugLog("[EpicManager] - Initialization of epic services complete.");
                }

                // Process epic services in a separate task.
                _ = UniTask.Run(Tick);

                // If we use the Auth interface then only login into the Connect interface after finishing the auth interface login
                // If we don't use the Auth interface we can directly login to the Connect interface
                if (_authInterfaceLogin)
                {
                    if (_authInterfaceCredentialType == LoginCredentialType.Developer)
                    {
                        _authInterfaceLoginCredentialId = $"localhost:{_devAuthToolPort}";
                        _authInterfaceCredentialToken   = _devAuthToolName;
                    }

                    // Login to Auth Interface
                    LoginOptions loginOptions = new LoginOptions
                    {
                        Credentials = new OnlineServices.Auth.Credentials
                        {
                            Type  = _authInterfaceCredentialType,
                            Id    = _authInterfaceLoginCredentialId,
                            Token = _authInterfaceCredentialToken
                        },
                        ScopeFlags = AuthScopeFlags.BasicProfile | AuthScopeFlags.FriendsList | AuthScopeFlags.Presence
                    };

                    AuthInterface.Login(loginOptions, null, OnAuthInterfaceLogin);
                }
                else
                {
                    // Login to Connect Interface
                    if (_connectInterfaceCredentialType == ExternalCredentialType.DeviceidAccessToken)
                    {
                        CreateDeviceIdOptions createDeviceIdOptions =
                            new CreateDeviceIdOptions
                        {
                            DeviceModel = Application.platform.ToString()
                        };
                        ConnectInterface.CreateDeviceId(createDeviceIdOptions, null, OnCreateDeviceId);
                    }
                    else
                    {
                        ConnectInterfaceLogin();
                    }
                }

                OnInitialized?.Invoke();

                return;
            }

            DebugLogger.RegularDebugLog(
                $"[EpicManager] - Failed to create platform. Ensure the relevant {typeof(Options)} are set or passed into the application as arguments.");
        }