MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / pair_global_service

Function pair_global_service

packages/server/src/main.rs:2762–2840  ·  view source on GitHub ↗
(options: PairGlobalServiceOptions)

Source from the content-addressed store, hash-verified

2760}
2761
2762fn pair_global_service(options: PairGlobalServiceOptions) -> anyhow::Result<()> {
2763 let PairGlobalServiceOptions {
2764 port,
2765 bind,
2766 advertise_host,
2767 client_root,
2768 video_codec,
2769 android_gpu,
2770 low_latency,
2771 stream_quality,
2772 local_stream_fps,
2773 json,
2774 } = options;
2775
2776 if port.is_none() {
2777 print_pair_progress("checking the installed service port");
2778 }
2779 let requested_port = match port {
2780 Some(port) => port,
2781 None => service::installed_port()?.unwrap_or(SERVICE_PORT),
2782 };
2783 print_pair_progress(format!("requesting port {requested_port}"));
2784
2785 print_pair_progress("detecting LAN and Tailscale addresses");
2786 let advertise_host = advertise_host.or_else(|| {
2787 detect_lan_ip()
2788 .or_else(detect_tailscale_ip)
2789 .map(|ip| ip.to_string())
2790 });
2791
2792 print_pair_progress("starting or reusing the global SimDeck service");
2793 if service::active()?.is_none() && stop_singleton_service_on_port(requested_port)? {
2794 print_pair_progress(format!(
2795 "stopped foreground service on port {requested_port} before installing LaunchAgent"
2796 ));
2797 }
2798 cleanup_orphaned_workspace_services_for_root(None);
2799 let result = service::pair(ServiceOptions {
2800 port: requested_port,
2801 bind,
2802 advertise_host,
2803 client_root,
2804 video_codec,
2805 android_gpu,
2806 low_latency,
2807 stream_quality_profile: local_stream_quality_profile(low_latency, stream_quality),
2808 local_stream_fps,
2809 access_token: None,
2810 pairing_code: None,
2811 })?;
2812 if result.reused {
2813 print_pair_progress(format!(
2814 "using {} on port {}; logs: {}, {}",
2815 result.service,
2816 result.port,
2817 result.stdout_log.display(),
2818 result.stderr_log.display()
2819 ));

Callers 1

mainFunction · 0.85

Calls 10

print_pair_progressFunction · 0.85
installed_portFunction · 0.85
detect_lan_ipFunction · 0.85
activeFunction · 0.85
pairFunction · 0.85
wait_for_pairing_targetFunction · 0.85
print_pairing_resultFunction · 0.85

Tested by

no test coverage detected