public void TestRewardHandlerMultipleApiCallsInBundle()
        {
            m_rewardCallbackHitCount = 0;

            TestResult tr = new TestResult();

            BrainCloudClient.Instance.PlayerStateService.ResetUser(tr.ApiSuccess, tr.ApiError);
            tr.Run();

            Dictionary <string, object> event1 = new Dictionary <string, object> {
                { "eventName", "incQuest1Stat" }, { "eventMultiplier", 1 }
            };

            Dictionary <string, object>[] jsonData1 = new Dictionary <string, object>[] { event1 };
            Dictionary <string, object>   event2    = new Dictionary <string, object> {
                { "eventName", "incQuest2Stat" }, { "eventMultiplier", 1 }
            };

            Dictionary <string, object>[] jsonData2 = new Dictionary <string, object>[] { event2 };

            BrainCloudClient.Get().RegisterRewardCallback(rewardCallback);
            BrainCloudClient.Instance.PlayerStatisticsEventService.TriggerStatsEvents(
                JsonWriter.Serialize(jsonData1),
                tr.ApiSuccess, tr.ApiError);
            BrainCloudClient.Instance.PlayerStatisticsEventService.TriggerStatsEvents(
                JsonWriter.Serialize(jsonData2),
                tr.ApiSuccess, tr.ApiError);
            tr.RunExpectCount(2);

            BrainCloudClient.Get().DeregisterRewardCallback();

            Assert.AreEqual(m_rewardCallbackHitCount, 2);
        }
예제 #2
0
        static int Main(string[] args)
        {
            TestResult tr = new TestResult();

            BrainCloudClient.Get().AuthenticationService.AuthenticateUniversal("abc", "abc", true, tr.ApiSuccess, tr.ApiError);
            if (tr.Run())
            {
                // something
            }
            return(0);
        }
예제 #3
0
        private void Spin()
        {
            long maxWait = m_timeToWaitSecs * 1000;

            while (!m_done && maxWait > 0)
            {
                BrainCloudClient.Get().Update();
                Thread.Sleep(10);
                maxWait -= 10;
            }
        }
예제 #4
0
    public static BrainCloudWrapper GetInstance()
    {
        if (!BrainCloudClient.EnableSingletonMode)
#pragma warning disable 162
        {
            throw new Exception(BrainCloudClient.SingletonUseErrorMessage);
        }
#pragma warning restore 162

        if (_applicationIsQuitting)
        {
            return(null);
        }
        if (_instance == null)
        {
#if !DOT_NET
            _instance = (BrainCloudWrapper)FindObjectOfType(typeof(BrainCloudWrapper));
            if (_instance != null)
            {
                _instance.Reauthenticate();
            }

            if (FindObjectsOfType(typeof(BrainCloudWrapper)).Length > 1)
            {
                Debug.LogError("[Singleton] Something went really wrong " +
                               " - there should never be more than 1 singleton!" +
                               " Reopening the scene might fix it.");
                return(_instance);
            }

            if (_instance == null)
            {
                GameObject go = new GameObject(GAMEOBJECT_BRAINCLOUD);

                _instance = go.AddComponent <BrainCloudWrapper>();
#pragma warning disable 618
                _instance.Client = BrainCloudClient.Get();
#pragma warning restore 618

                DontDestroyOnLoad(go);
            }
#else
            _instance = new BrainCloudWrapper(BrainCloudClient.Get());
#endif
            _instance.LoadData();
        }
        return(_instance);
    }
예제 #5
0
        public void TestAuthenticateWithHeartbeat()
        {
            TestResult tr = new TestResult();

            // Insert heartbeat as first packet. This would normally cause the
            // server to reject the second authenticate packet but with the
            // new comms change, this should result in the heartbeat being
            // removed from the message bundle.
            BrainCloudClient.Get().SendHeartbeat();

            BrainCloudClient.Get().AuthenticationService.AuthenticateEmailPassword(
                GetUser(Users.UserA).Email,
                GetUser(Users.UserA).Password,
                true,
                tr.ApiSuccess, tr.ApiError);

            tr.Run();
        }
예제 #6
0
        public void TestMessageCache()
        {
            try
            {
                BrainCloudClient.Get().Initialize(ServerUrl + "unitTestFail", Secret, AppId, Version);
                BrainCloudClient.Get().EnableNetworkErrorMessageCaching(true);
                BrainCloudClient.Get().EnableLogging(true);
                BrainCloudClient.Get().SetPacketTimeouts(new List <int> {
                    1, 1, 1
                });

                DateTime   timeStart = DateTime.Now;
                TestResult tr        = new TestResult();
                tr.SetTimeToWaitSecs(30);
                BrainCloudClient.Get().RegisterNetworkErrorCallback(tr.NetworkError);
                BrainCloudClient.Get().AuthenticationService.AuthenticateUniversal("abc", "abc", true, tr.ApiSuccess, tr.ApiError);
                tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);

                BrainCloudClient.Get().RetryCachedMessages();
                tr.Reset();
                tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);

                BrainCloudClient.Get().FlushCachedMessages(true);
                // unable to catch the api callback in this case using tr...

                //tr.Reset();
                //tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);
            }
            finally
            {
                // reset to defaults
                BrainCloudClient.Get().SetPacketTimeoutsToDefault();
                BrainCloudClient.Get().EnableNetworkErrorMessageCaching(false);
                BrainCloudClient.Get().DeregisterNetworkErrorCallback();
            }
        }
 public BrainCloudWrapper()
 {
     m_client = BrainCloudClient.Get();
 }