Example #1
0
        public void LoginByType(LoginType type, Action <TDSGlobalUser> callback, Action <TDSGlobalError> errorCallback)
        {
            var command = new Command.Builder()
                          .Args("loginByType", (int)type)
                          .Service(TDSGlobalBridgeName.LOGIN_SERVICE_NAME)
                          .Method("loginByType")
                          .Callback(true)
                          .OnceTime(false)
                          .CommandBuilder();

            EngineBridge.GetInstance().CallHandler(command, (result) =>
            {
                Debug.Log("login result:" + result.toJSON());

                if (!checkResultSuccess(result))
                {
                    errorCallback(new TDSGlobalError(TDSGlobalUnKnowError.UN_KNOW, $"Login Failed:{result.message}"));
                    return;
                }

                TDSGlobalUserWrapper userWrapper = new TDSGlobalUserWrapper(result.content);
                if (userWrapper.error != null)
                {
                    errorCallback(userWrapper.error);
                    return;
                }

                if (userWrapper.user != null)
                {
                    callback(userWrapper.user);
                }
            });
        }
Example #2
0
        public void Login(Action <TDSGlobalUser> callback, Action <TDSGlobalError> errorCallback)
        {
            Command command = new Command(TDSGlobalBridgeName.LOGIN_SERVICE_NAME, "login", true, null);

            EngineBridge.GetInstance().CallHandler(command, (result) =>
            {
                Debug.Log("login result:" + result.toJSON());

                if (!checkResultSuccess(result))
                {
                    errorCallback(new TDSGlobalError(TDSGlobalUnKnowError.UN_KNOW, $"Login Failed:{result.message}"));
                    return;
                }

                TDSGlobalUserWrapper userWrapper = new TDSGlobalUserWrapper(result.content);
                if (userWrapper.error != null)
                {
                    errorCallback(userWrapper.error);
                    return;
                }

                if (userWrapper.user != null)
                {
                    callback(userWrapper.user);
                }
            });
        }