Esempio n. 1
0
        public bool RegisterByEmail(AccountServiceRequest request, Action <AccountServiceResponse> callback = null,
                                    Action <string> errorCallback = null)
        {
            if (request == null)
            {
                Debug.LogError("Registration request is null");
                return(false);
            }

            StartCoroutine(
                HttpPost(GetUrlWithQueryStringEscaped(request),
                         requestHeaders,
                         null,
                         s =>
            {
                if (string.IsNullOrEmpty(s))
                {
                    if (errorCallback != null)
                    {
                        errorCallback(
                            "Server's response was empty. Please register through account website during this service interruption.");
                    }
                }
                else
                {
                    var ase = ParseResult(s);
                    if (ase == null)
                    {
                        if (errorCallback != null)
                        {
                            errorCallback(
                                "Error parsing registration response. Please try registering from account website");
                        }
                    }
                    else if (callback != null)
                    {
                        callback(ase);
                    }
                }
            },
                         e =>
            {
                if (errorCallback != null)
                {
                    errorCallback(e);
                }
            })
                );
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Attempts to create a Photon Cloud Account asynchronously.
        /// Once your callback is called, check ReturnCode, Message and AppId to get the result of this attempt.
        /// </summary>
        /// <param name="email">Email of the account.</param>
        /// <param name="serviceTypes">Defines which type of Photon-service is being requested.</param>
        /// <param name="callback">Called when the result is available.</param>
        public bool RegisterByEmail(string email, string serviceTypes, Action <AccountServiceResponse> callback = null,
                                    Action <string> errorCallback = null)
        {
            if (IsValidEmail(email) == false)
            {
                Debug.LogErrorFormat("Email \"{0}\" is not valid", email);
                return(false);
            }

            if (string.IsNullOrEmpty(serviceTypes))
            {
                Debug.LogError("serviceTypes string is null or empty");
                return(false);
            }

            var req = new AccountServiceRequest();

            req.Email        = email;
            req.ServiceTypes = serviceTypes;
            return(RegisterByEmail(req, callback, errorCallback));
        }