예제 #1
0
    // private IEnumerator logout() {
    //  setStatus(RESTARTING_SESSION);
    //  logoutLoaded = false;
    //
    //  webView.url = ServerInteract.LOGOUT_URL;
    //  webView.Load();
    //
    //  while (!logoutLoaded) {
    //      yield return null;
    //  }
    //
    //  if (clearCache) {
    //      webView.CleanCache ();
    //      webView.CleanCookie ();
    //  }
    //
    //  setStatus (SESSION_RESTARTED);
    //
    //  yield return "Done";
    // }
    //
    // private IEnumerator tryAutoLogin() {
    //  setStatus (START_AUTO_LOGIN);
    //  autoLoginWorked = false;
    //
    //  SavedCredentials savedCreds = readTokenAndUsernameFromFile ();
    //  if (savedCreds != null) {
    //      setStatus(REAUTHORIZING_SAVED_TOKEN);
    //
    //      authToken = savedCreds.savedAuthtoken;
    //
    //      ServerCall testSavedAuth = new ServerCall(ServerInteract.INSTANCE.SendServerInformationRequest (ServerInteract.TEST_LOGIN, null));
    //      yield return StartCoroutine (testSavedAuth.call ());
    //
    //
    //      if(testSavedAuth.ReturnException == null) {
    //
    //          setStatus(SAVED_TOKEN_SUCCESS);
    //
    //          authToken = savedCreds.savedAuthtoken;
    //          StartCoroutine(startLoadUserData ());
    //          autoLoginWorked = true;
    //
    //      } else {
    //          setStatus (SAVED_TOKEN_FAILED);
    //
    //          authToken = null;
    //
    //          if (savedCreds.savedProvider.Equals (AUTH_0_LOGIN_PROVIDER)) {
    //              setStatus (PROVIDER_AUTH_0);
    //              autoLoginWorked = false;
    //          } else {
    //              setStatus (AUTHORIZING_WITH_PROVIDER + savedCreds.savedProvider);
    //              loadReauthorize (savedCreds.savedProvider);
    //              autoLoginWorked = true;
    //          }
    //      }
    //  } else { // create a blank file if none is there and login has failed
    //
    //      autoLoginWorked = false;
    //  }
    //
    //  yield return "Done";
    // }

    // private void loadReauthorize(string provider) {
    //  string authorizeurl = createAuthorizeURL (provider);
    //
    //  webView.url = authorizeurl;
    //  webView.Load ();
    // }

    // private void loadManualLogin() {
    //  setStatus(LOADING_MANUAL_LOGIN);
    //
    //  webView.url = ServerInteract.MANUALLOGIN;
    //  webView.Load();
    //
    //  setStatus (MANUAL_LOGIN_LOADED);
    // }

    // void OnLoadComplete(UniWebView webView, bool success, string errorMessage) {
    //  Debug.Log ("Load complete: " + webView.url);
    //  Debug.Log ("Load successful: " + success);
    //
    //  if (webView.url.Equals (ServerInteract.LOGOUT_URL)) {
    //      logoutLoaded = true;
    //  } else if (webView.url.Equals (ServerInteract.MANUALLOGIN)) {
    //      webView.Show();
    //  } else if (webView.url.Contains (ServerInteract.AUTHORIZEURL)) {
    //      webView.Show();
    //  }
    //
    //  if (!success) {
    //      Debug.Log("Something wrong in webview loading: " + errorMessage);
    //  }
    //
    // }
    //
    // void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) {
    //
    //  // You can check the message path and arguments to know which `uniwebview` link is clicked.
    //  // UniWebView will help you to parse your link if it follows the url argument format.
    //  // However, there is also a "rawMessage" property you could use if you need to use some other formats and want to parse it yourself.
    //  Debug.Log("Received message from: " + webView.url);
    //  Debug.Log ("Raw message: " + message.rawMessage);
    //
    //  if (message.path == "success") {
    //      string response = message.args["authToken"].Trim();
    //      authToken = response;
    //
    //      Debug.LogWarning("Auth token: " + authToken);
    //
    //      //writeTokenToFile (authToken);
    //      //LoadUserData.populateUserData(authToken);
    //      //LoadUserData lud = new LoadUserData();
    //      //StartCoroutine (lud.Start());
    //
    //      StartCoroutine(startLoadUserData ());
    //  }
    // }

    // This method will be called when the screen orientation changed. Here we return UniWebViewEdgeInsets(5,5,5,5)
    // for both situation, which means the inset is 5 point for iOS and 5 pixels for Android from all edges.
    // Note: UniWebView is using point instead of pixel in iOS. However, the `Screen.width` and `Screen.height` will give you a
    // pixel-based value.
    // You could get a point-based screen size by using the helper methods: `UniWebViewHelper.screenHeight` and `UniWebViewHelper.screenWidth` for iOS.
    // UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation) {
    //  int INSET = 0;
    //  if (orientation == UniWebViewOrientation.Portrait) {
    //      return new UniWebViewEdgeInsets(INSET,INSET,INSET,INSET);
    //  } else {
    //      return new UniWebViewEdgeInsets(INSET,INSET,INSET,INSET);
    //  }
    // }

    private IEnumerator startLoadUserData()
    {
        HardwareController.initialize();

        setStatus("Downloading User Profile...");

        ServerCall waitFor = new ServerCall(ServerInteract.INSTANCE.GetLoggedInUserInfo());

        yield return(StartCoroutine(waitFor.call()));

        writeTokenAndUsernameToFile(authToken, LoggedInUser.GetLoggedInUser().GetUserId());

        setStatus("Logging into Network...");
        waitFor = new ServerCall(ServerInteract.INSTANCE.RetrieveFirebaseToken());
        yield return(StartCoroutine(waitFor.call()));

        SceneManager.LoadScene("Scenes/GroundViewScene", LoadSceneMode.Single);
    }