Пример #1
0
 public static void Register()
 {
     PlayFabSettings.RegisterForRequests(null, _onRequestGl);
     PlayFabSettings.RegisterForResponses(null, _onResponseGl);
     PlayFabSettings.RegisterForRequests("/Client/LoginWithCustomID", _onRequestLogin);
     PlayFabSettings.RegisterForResponses("/Client/LoginWithCustomID", _onResponseLogin);
 }
Пример #2
0
        public void Awake()
        {
            // Instance methods must be cast to a delegate inside the registration function
            PlayFabSettings.RequestCallback <object> onApiRequestInstGl = OnApiRequest_InstGl;                            // Generic callbacks have to use the generic signature
            PlayFabSettings.ResponseCallback <object, PlayFabResultCommon> onApiResponseInstGl    = OnApiResponse_InstGl; // Generic callbacks have to use the generic signature
            PlayFabClientAPI.LoginWithEmailAddressRequestCallback          onApiRequestInstLogin  = OnApiRequest_InstLogin;
            PlayFabClientAPI.LoginWithEmailAddressResponseCallback         onApiResponseInstLogin = OnApiResponse_InstLogin;
            PlayFabSettings.RequestCallback <object> onApiRequestInstLogin2 = OnApiRequest_InstLogin2;                         // Generic callbacks have to use the generic signature
            PlayFabSettings.ResponseCallback <object, PlayFabResultCommon> onApiResponseInstLogin2 = OnApiResponse_InstLogin2; // Generic callbacks have to use the generic signature

            // Registering for instance methods, using the local delegate variables (bound to the "this" instance)
            PlayFabSettings.RegisterForRequests(null, onApiRequestInstGl);
            PlayFabSettings.RegisterForResponses(null, onApiResponseInstGl);
            PlayFabSettings.RegisterForRequests("/Client/LoginWithEmailAddress", onApiRequestInstLogin);
            PlayFabSettings.RegisterForResponses("/Client/LoginWithEmailAddress", onApiResponseInstLogin);
            PlayFabSettings.RegisterForRequests("/Client/LoginWithAndroidDeviceID", onApiRequestInstLogin2);
            PlayFabSettings.RegisterForResponses("/Client/LoginWithAndroidDeviceID", onApiResponseInstLogin2);
            PlayFabSettings.RegisterForRequests("/Client/LoginWithIOSDeviceID", onApiRequestInstLogin2);
            PlayFabSettings.RegisterForResponses("/Client/LoginWithIOSDeviceID", onApiResponseInstLogin2);

            // Registering for static methods, using the static delegate variables defined by each function
            PlayFabSettings.RegisterForRequests(null, _onApiRequestStGl);
            PlayFabSettings.RegisterForResponses(null, _onApiResponseStGl);
            PlayFabSettings.RegisterForRequests("/Client/LoginWithEmailAddress", _onApiRequestStLogin);
            PlayFabSettings.RegisterForResponses("/Client/LoginWithEmailAddress", _onApiResponseStLogin);
            PlayFabSettings.RegisterForRequests("/Client/LoginWithAndroidDeviceID", _onApiRequestStLogin2);
            PlayFabSettings.RegisterForResponses("/Client/LoginWithAndroidDeviceID", _onApiResponseStLogin2);
            PlayFabSettings.RegisterForRequests("/Client/LoginWithIOSDeviceID", _onApiRequestStLogin2);
            PlayFabSettings.RegisterForResponses("/Client/LoginWithIOSDeviceID", _onApiResponseStLogin2);
        }
Пример #3
0
            public void Register()
            {
                // Instance methods must be cast to a delegate inside the registration function
                PlayFabSettings.RequestCallback <object> onRequestInstGl = OnRequest_InstGl;                         // Generic callbacks have to use the generic signature
                PlayFabSettings.ResponseCallback <object, PlayFabResultCommon> onResponseInstGl = OnResponse_InstGl; // Generic callbacks have to use the generic signature
                PlayFabClientAPI.LoginWithCustomIDRequestCallback  onRequestInstLogin           = OnRequest_InstLogin;
                PlayFabClientAPI.LoginWithCustomIDResponseCallback onResponseInstLogin          = OnResponse_InstLogin;

                // Registering for instance methods, using the local delegate variables (bound to the "this" instance)
                PlayFabSettings.RegisterForRequests(null, onRequestInstGl);
                PlayFabSettings.RegisterForResponses(null, onResponseInstGl);
                PlayFabSettings.RegisterForRequests("/Client/LoginWithCustomID", onRequestInstLogin);
                PlayFabSettings.RegisterForResponses("/Client/LoginWithCustomID", onResponseInstLogin);
            }
Пример #4
0
        public void TestCallbackFailures()
        {
            PlayFabSettings.HideCallbackErrors = true;
            // Just need any valid auth token for this test
            LoginWithCustomIDRequest loginRequest = new LoginWithCustomIDRequest();

            loginRequest.CreateAccount = true;
            loginRequest.CustomId      = "Custom ID";        //SystemInfo.deviceUniqueIdentifier;
            PlayFabClientAPI.LoginWithCustomID(loginRequest, null, null);
            WaitForApiCalls();

            PlayFabSettings.RegisterForResponses(null, (PlayFabSettings.ResponseCallback <object, PlayFabResultCommon>)SuccessCallback_Global);
            PlayFabSettings.GlobalErrorHandler += SharedError_Global;
            callbacks.Clear();

            GetCatalogItemsRequest catalogRequest = new GetCatalogItemsRequest();

            PlayFabClientAPI.GetCatalogItems(catalogRequest, GetCatalogItemsCallback_Single, SharedError_Single);
            WaitForApiCalls();
            UUnitAssert.True(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // All success callbacks should occur, even if some throw exceptions
            UUnitAssert.True(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global");                 // All success callbacks should occur, even if some throw exceptions
            UUnitAssert.False(callbacks.Contains("SharedError_Single"), "SharedError_Single");                        // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions)
            UUnitAssert.False(callbacks.Contains("SharedError_Global"), "SharedError_Global");                        // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions)
            UUnitAssert.IntEquals(2, callbacks.Count);
            callbacks.Clear();

            RegisterPlayFabUserRequest registerRequest = new RegisterPlayFabUserRequest();

            PlayFabClientAPI.RegisterPlayFabUser(registerRequest, RegisterPlayFabUserCallback_Single, SharedError_Single);
            WaitForApiCalls();
            UUnitAssert.False(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // Success should not have occurred
            UUnitAssert.False(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global");                 // Success should not have occurred
            UUnitAssert.True(callbacks.Contains("SharedError_Single"), "SharedError_Single");                          // All error callbacks should occur, even if some throw exceptions
            UUnitAssert.True(callbacks.Contains("SharedError_Global"), "SharedError_Global");                          // All error callbacks should occur, even if some throw exceptions
            UUnitAssert.IntEquals(2, callbacks.Count);
            callbacks.Clear();
            PlayFabSettings.HideCallbackErrors = false;
            PlayFabSettings.ForceUnregisterAll();
        }