/// <summary> /// Starts the connection by calling into Limelight Common /// </summary> private async Task StartConnection() { NvHttp nv = null; await SetStateText("Resolving hostname..."); try { nv = new NvHttp(selected.IpAddress); } catch (ArgumentNullException) { stageFailureText = "Error resolving hostname"; ConnectionFailed(); } XmlQuery launchApp; // Launch Steam await SetStateText("Launching Steam"); try { launchApp = new XmlQuery(nv.baseUrl + "/launch?uniqueid=" + nv.GetDeviceName() + "&appid=" + selected.steamID); } catch (Exception) { Debug.WriteLine("Can't find steam"); stageFailureText = "Error launching Steam"; ConnectionFailed(); return; } // Set up callbacks LimelightStreamConfiguration streamConfig = new LimelightStreamConfiguration(frameWidth, frameHeight, 30, 10000, 1024); // TODO a magic number. Get FPS from the settings LimelightDecoderRenderer drCallbacks = new LimelightDecoderRenderer(DrSetup, DrStart, DrStop, DrRelease, DrSubmitDecodeUnit); LimelightAudioRenderer arCallbacks = new LimelightAudioRenderer(ArInit, ArStart, ArStop, ArRelease, ArPlaySample); LimelightConnectionListener clCallbacks = new LimelightConnectionListener(ClStageStarting, ClStageComplete, ClStageFailed, ClConnectionStarted, ClConnectionTerminated, ClDisplayMessage, ClDisplayTransientMessage); // Call into Common to start the connection Debug.WriteLine("Starting connection"); uint addr = 0; //uint addr = (uint)nv.resolvedHost.ToString(); // TODO how to get the addr as a uint LimelightCommonRuntimeComponent.StartConnection(addr, streamConfig, clCallbacks, drCallbacks, arCallbacks); if (stageFailureText != null) { Debug.WriteLine("Stage failed"); ConnectionFailed(); return; } else { ConnectionSuccess(); } }
/// <summary> /// Pair with the hostname in the textbox /// </summary> private async Task Pair(string uri) { Debug.WriteLine("Pairing "); // Create NvHttp object with the user input as the URL try { nv = new NvHttp(uri); } catch (Exception) { var dialog = new MessageDialog("Invalid Hostname", "Pairing Failed"); dialog.ShowAsync(); return; } // Get the server IP address try { await nv.GetServerIPAddress(); } catch (Exception e) { var dialog = new MessageDialog("Error resolving hostname " + e.Message, "Pairing Failed"); dialog.ShowAsync(); return; } if (await QueryPairState()) { Debug.WriteLine("Already paired"); return; } Challenges(nv.GetDeviceName()); // Otherwise, everything was successful var successDialog = new MessageDialog("Pairing successful", "Success"); await successDialog.ShowAsync(); }