Exemplo n.º 1
0
        private IEnumerator WaitThenOpen(ClaimData responce)
        {
            yield return(new WaitForSeconds(0.5f));

            string claimSanitized = UnityWebRequest.EscapeURL(responce.claimToken);
            string openUrl        = url + "/externalSignIn?claimToken=" + claimSanitized;

            Application.OpenURL(openUrl);

            pollClaim(responce.claimToken);
        }
Exemplo n.º 2
0
        private void onLoginClick()
        {
            urlTitle.gameObject.SetActive(false);
            urlInput.gameObject.SetActive(false);
            warningInfo.gameObject.SetActive(false);

            newSession.gameObject.SetActive(false);

            connectionInfo.gameObject.SetActive(true);
            loadingCircle.gameObject.SetActive(true);

            // Content of the body is ignored
            byte[] emptyBody = Serial.toBSON(new { });
            url = urlInput.text.Trim('/');

            StartCoroutine(HTTPHelpers.post(url + "/api/v1/authentication/claims?bson=true",
                                            emptyBody,
                                            string.Empty,
                                            (data) =>
            {
                openingInfo.gameObject.SetActive(true);
                connectionInfo.gameObject.SetActive(false);

                try
                {
                    ClaimData responce = Serial.fromBSON <ClaimData>(data);

                    StartCoroutine(WaitThenOpen(responce));
                }
                catch (Exception e)
                {
                    sessionInfo.text = "Error deserializing BSON response: " + e;
                    Debug.Log(e);
                    newSession.gameObject.SetActive(true);
                }
            }, (error) =>
            {
                showError(error);
            })
                           );
        }