pairGetTokens() public method

public pairGetTokens ( string redirectUri ) : string
redirectUri string
return string
コード例 #1
0
ファイル: Pairing.cs プロジェクト: yodiwo/plegma
        public int SpinDelay = 1000; //in miliseconds

        public bool StartPair(string frontendUrl, string redirectUri, NodeConfig conf, string selfUrl, NodePairingBackend.OnPairedDelegate OnPairedcb, NodePairingBackend.OnPairingFailedDelegate OnPairingFailedCB)
        {
            this.conf = conf;

            //pairing backend
            var backend = new NodePairingBackend(frontendUrl, conf, OnPairedcb, OnPairingFailedCB);
            string token2 = backend.pairGetTokens(redirectUri);
            pairingURI = backend.pairingPostUrl + "/" + API.Plegma.NodePairing.NodePairingConstants.UserConfirmPageURI + "?token2=" + token2;

            if (UriCustomLauncher != null)
                UriCustomLauncher(pairingURI);
            else
            {
#if NETFX
                Process.Start(pairingURI);
#else
                Windows.System.Launcher.LaunchUriAsync(new Uri(pairingURI)).AsTask();
#endif
            }

            //wait for finish
            Task.Delay(1000).Wait();
            Task.Run(() =>
            {
                while (true)
                {
                    var keys = backend.pairGetKeys();
                    if (keys != null)
                        break;
                    Task.Delay(SpinDelay).Wait();
                }
            });
            return true;
        }
コード例 #2
0
ファイル: Pairing.cs プロジェクト: sm6uax/plegma
        public int SpinDelay = 1000; //in miliseconds

        public bool StartPair(string frontendUrl, string redirectUri, NodeConfig conf, string selfUrl, NodePairingBackend.OnPairedDelegate OnPairedcb, NodePairingBackend.OnPairingFailedDelegate OnPairingFailedCB)
        {
            this.conf = conf;

            //pairing backend
            var    backend = new NodePairingBackend(frontendUrl, conf, OnPairedcb, OnPairingFailedCB);
            string token2  = backend.pairGetTokens(redirectUri);

            pairingURI = backend.pairingPostUrl + "/" + API.Plegma.NodePairing.NodePairingConstants.UserConfirmPageURI + "?token2=" + token2;

            if (UriCustomLauncher != null)
            {
                UriCustomLauncher(pairingURI);
            }
            else
            {
#if NETFX
                Process.Start(pairingURI);
#else
                Windows.System.Launcher.LaunchUriAsync(new Uri(pairingURI)).AsTask();
#endif
            }

            //wait for finish
            Task.Delay(1000).Wait();
            Task.Run(() =>
            {
                while (true)
                {
                    var keys = backend.pairGetKeys();
                    if (keys != null)
                    {
                        if (keys.Item1.IsValid && keys.Item2 != null && keys.Item3 == System.Net.HttpStatusCode.OK)
                        {
                            return(true);
                        }

                        if (keys.Item3 == System.Net.HttpStatusCode.Forbidden ||
                            keys.Item3 == System.Net.HttpStatusCode.BadRequest)
                        {
                            return(false);
                        }

                        Task.Delay(SpinDelay).Wait();
                    }
                }
            });
            return(true);
        }