protected void oAuth2Legged()
        {
            oAuth2Legged rest = new oAuth2Legged(CLIENTID, CLIENTSECRET);

            rest.FireRequest(
                (object sender, AsyncCompletedEventArgs args) => {
                if (args == null || args.UserState == null)
                {
                    return;
                }
                if (args.Error != null)
                {
                    UnityMainThreadDispatcher.Instance().Enqueue(() => {
                        Debug.Log(ForgeLoader.GetCurrentMethod() + " " + args.Error.Message);
                    });
                    return;
                }

                //UploadValuesCompletedEventArgs args2 =args as UploadValuesCompletedEventArgs ;
                //byte[] data =args2.Result ;
                //string textData =System.Text.Encoding.UTF8.GetString (data) ;

                UploadValuesCompletedEventArgs args2 = args as UploadValuesCompletedEventArgs;
                string textData = Encoding.UTF8.GetString(args2.Result);

                JSONNode json = JSON.Parse(textData);

                BEARER = json ["access_token"];
                UnityMainThreadDispatcher.Instance().Enqueue(() => {
                    oAuthCompleted.Invoke(BEARER);
                });

                if (LOADERS != null)
                {
                    UnityMainThreadDispatcher.Instance().Enqueue(() => {
                        for (int i = 0; i < LOADERS.Count; i++)
                        {
                            GameObject loader       = LOADERS [i];
                            ForgeLoader forgeLoader = loader.GetComponent <ForgeLoader> ();
                            forgeLoader.BEARER      = BEARER;
                            if (string.IsNullOrEmpty(forgeLoader.URN) || string.IsNullOrEmpty(forgeLoader.SCENEID))
                            {
                                continue;
                            }
                            loader.SetActive(true);
                        }
                    });
                }
            }
                );
        }
예제 #2
0
        public void oAuth2Legged()
        {
            oAuth2Legged rest = new oAuth2Legged();

            rest.FireRequest(
                (object sender, AsyncCompletedEventArgs args) => {
                if (args == null || args.UserState == null)
                {
                    return;
                }
                if (args.Error != null)
                {
                    UnityMainThreadDispatcher.Instance().Enqueue(() => {
                        Debug.Log(Autodesk.Forge.ARKit.ForgeLoader.GetCurrentMethod() + " " + args.Error.Message);
                    });
                    return;
                }

                //UploadValuesCompletedEventArgs args2 =args as UploadValuesCompletedEventArgs ;
                //byte[] data =args2.Result ;
                //string textData =System.Text.Encoding.UTF8.GetString (data) ;

                UploadStringCompletedEventArgs args2 = args as UploadStringCompletedEventArgs;
                string textData = args2.Result;

                JSONNode json = JSONNode.Parse(textData);

                bearer = json ["access_token"];
                UnityMainThreadDispatcher.Instance().Enqueue(() => {
                    oAuthCompleted.Invoke(bearer);
                });

                if (loader != null)
                {
                    UnityMainThreadDispatcher.Instance().Enqueue(() => {
                        ForgeLoader forgeLoader = loader.GetComponent <ForgeLoader> ();
                        forgeLoader.BEARER      = bearer;
                        if (string.IsNullOrEmpty(forgeLoader.URN) || string.IsNullOrEmpty(forgeLoader.SCENEID))
                        {
                            return;
                        }
                        loader.SetActive(true);
                    });
                }
            }
                );
        }