Esempio n. 1
0
        /// <summary>
        /// Create start HTTP request
        /// </summary>
        private XmlQuery StartOrResumeApp(NvHttp nv, LimelightStreamConfiguration streamConfig)
        {
            XmlQuery serverInfo = new XmlQuery(nv.baseUrl + "/serverinfo?uniqueid=" + nv.GetUniqueId());
            string currentGameString = serverInfo.XmlAttribute("currentgame");

            byte[] aesIv = streamConfig.GetRiAesIv();
            int riKeyId =
                (int)(((aesIv[0] << 24) & 0xFF000000) |
                ((aesIv[1] << 16) & 0xFF0000) |
                ((aesIv[2] << 8) & 0xFF00) |
                (aesIv[3] & 0xFF));
            string riConfigString =
                "&rikey=" + Pairing.bytesToHex(streamConfig.GetRiAesKey()) +
                "&rikeyid=" + riKeyId;

            // Launch a new game if nothing is running
            if (currentGameString == null || currentGameString.Equals("0"))
            {
                return new XmlQuery(nv.baseUrl + "/launch?uniqueid=" + nv.GetUniqueId() + "&appid=" + selected.steamID +
                    "&mode=" + streamConfig.GetWidth() + "x" + streamConfig.GetHeight() + "x" + streamConfig.GetFps() +
                    "&additionalStates=1&sops=1" + // FIXME: make sops configurable
                    riConfigString);
            }
            else
            {
                // A game was already running, so resume it
                // FIXME: Quit and relaunch if it's not the game we came to start
                return new XmlQuery(nv.baseUrl + "/resume?uniqueid=" + nv.GetUniqueId() + riConfigString);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Pair with the hostname in the textbox
        /// </summary>
        public async Task Pair(Computer c)
        {
            Debug.WriteLine("Pairing ");
            // Create NvHttp object with the user input as the URL
            try
            {
                nv = new NvHttp(c.IpAddress);
            }
            catch (Exception)
            {
                var dialog = new MessageDialog("Invalid Hostname", "Pairing Failed");
                dialog.ShowAsync();
                return;
            }
            // Get the server IP address
            try
            {
                await nv.ServerIPAddress();
            }
            catch (Exception e)
            {
                var dialog = new MessageDialog("Error resolving hostname " + e.Message , "Pairing Failed");
                dialog.ShowAsync();
                return;
            }

            // "Please don't do this ever, but it's only okay because Cameron said so" -Cameron Gutman            
            getClientCertificate();

            // Get the pair state.
            bool? pairState = await QueryPairState(); 
            if (pairState == true)
            {
                var dialog = new MessageDialog("This device is already paired to the host PC", "Already Paired");
                dialog.ShowAsync();
                Debug.WriteLine("Already paired");
                return;
            }
                // pairstate = null. We've encountered an error
            else if (!pairState.HasValue)
            {
                var dialog = new MessageDialog("Failed to query pair state", "Pairing failed");
                dialog.ShowAsync();
                Debug.WriteLine("Query pair state failed");
                return;
            }
            bool challenge = await Challenges(nv.GetUniqueId());
            if (!challenge)
            {
                Debug.WriteLine("Challenges failed");
                return; 
            } 

            // Otherwise, everything was successful
            MainPage.SaveComputer(c);
            var successDialog = new MessageDialog("Pairing successful", "Success");
            await successDialog.ShowAsync();
        }