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

Function serve

packages/server/src/main.rs:5881–5977  ·  view source on GitHub ↗
(
    port: u16,
    bind: IpAddr,
    advertise_host: Option<String>,
    client_root: Option<PathBuf>,
    video_codec: VideoCodecMode,
    low_latency: bool,
    server_kind: ServerKind,
    access

Source from the content-addressed store, hash-verified

5879
5880#[allow(clippy::too_many_arguments)]
5881async fn serve(
5882 port: u16,
5883 bind: IpAddr,
5884 advertise_host: Option<String>,
5885 client_root: Option<PathBuf>,
5886 video_codec: VideoCodecMode,
5887 low_latency: bool,
5888 server_kind: ServerKind,
5889 access_token: Option<String>,
5890 pairing_code: Option<String>,
5891) -> anyhow::Result<()> {
5892 let root = match client_root {
5893 Some(root) => root,
5894 None => default_client_root()?,
5895 };
5896 let config = Config::new(
5897 port,
5898 root,
5899 bind,
5900 advertise_host,
5901 server_kind,
5902 video_codec.as_env_value().to_owned(),
5903 low_latency,
5904 access_token,
5905 pairing_code,
5906 );
5907 let metrics = Arc::new(Metrics::default());
5908 let bridge = NativeBridge;
5909 let registry = SessionRegistry::new(bridge, metrics.clone());
5910 let logs = LogRegistry::default();
5911 let inspectors = InspectorHub::with_registry(InspectorRegistryAdvertisement::new(&config));
5912 let state = AppState {
5913 config: config.clone(),
5914 registry,
5915 logs,
5916 inspectors,
5917 metrics,
5918 performance: PerformanceRegistry::default(),
5919 stream_clients: Default::default(),
5920 simulator_inventory: Default::default(),
5921 accessibility_cache: Default::default(),
5922 android: Default::default(),
5923 };
5924
5925 let http_router = app_router(
5926 state.clone(),
5927 config.client_root.clone(),
5928 config.access_token.clone(),
5929 );
5930 let http_listener = tokio::net::TcpListener::bind(config.http_addr())
5931 .await
5932 .with_context(|| format!("bind HTTP listener on {}", config.http_addr()))?;
5933 let health_heartbeat = Arc::new(AtomicU64::new(now_secs()));
5934 start_server_health_watchdog(config.http_addr(), health_heartbeat.clone());
5935 let _bonjour_advertisement = BonjourAdvertisement::start(&config);
5936
5937 info!("HTTP listening on http://{}", config.http_addr());
5938 info!("Serving client from {}", config.client_root.display());

Callers 1

serve_with_appkitFunction · 0.85

Calls 11

default_client_rootFunction · 0.85
app_routerFunction · 0.85
now_secsFunction · 0.85
startFunction · 0.85
start_quit_key_listenerFunction · 0.85
shutdown_signalFunction · 0.85
as_env_valueMethod · 0.80
http_addrMethod · 0.80
cloneMethod · 0.65
sleepFunction · 0.50

Tested by

no test coverage detected