### Install ALVR Flatpak Bundle Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak Install the ALVR Flatpak bundle by downloading the utility file and running this command in the terminal. This command installs it for the current user. ```sh flatpak install --user com.valvesoftware.Steam.Utility.alvr.flatpak ``` -------------------------------- ### Install Fedora Dependencies Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Install development tools and libraries for building ALVR on Fedora. ```bash sudo dnf groupinstall 'Development Tools' | For c++ and build tools sudo dnf install nasm yasm libdrm-devel vulkan-headers pipewire-jack-audio-connection-kit-devel atk-devel gdk-pixbuf2-devel cairo-devel rust-gdk0.15-devel x264-devel vulkan-devel libunwind-devel clang openssl-devel alsa-lib-devel libva-devel pipewire-devel git ``` -------------------------------- ### Setup WiredConnection for ADB Streaming Source: https://context7.com/alvr-org/alvr/llms.txt Initialize WiredConnection to manage ADB. Setup port forwarding and verify the ALVR client status. The connection automatically kills the ADB server on drop. ```rust use alvr_adb::{WiredConnection, WiredConnectionStatus}; use alvr_filesystem::Layout; use alvr_session::WiredClientAutoLaunchConfig; use alvr_system_info::ClientFlavor; let layout = Layout::new(std::path::Path::new("/opt/alvr")); // Download ADB if not present, then wrap it let conn = WiredConnection::new(&layout, |downloaded, total| { if let Some(total) = total { println!("ADB download: {downloaded}/{total} bytes"); } })?; // Try to set up port forwarding and verify client is active let status = conn.setup( /*control_port=*/9943, /*stream_port=*/9944, &ClientFlavor::Github, Some(WiredClientAutoLaunchConfig { boot_delay: 5 }), )?; match status { WiredConnectionStatus::Ready => println!("Wired client ready"), WiredConnectionStatus::NotReady(reason) => println!("Not ready: {reason}"), } // WiredConnection::drop() automatically kills the ADB server ``` -------------------------------- ### Set Android Environment Variables on Linux (General) Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Provides general examples for setting Android development environment variables on Linux. Specific paths may vary based on your distribution and installation method. ```bash JAVA_HOME: /usr/lib/jvm/default-java/bin ANDROID_HOME: Arch: ~/Android/Sdk Gentoo: ~/Android Debian / Ubuntu / Pop!_OS: ~/AndroidSDK ANDROID_NDK_HOME: Arch: /opt/android-sdk/ndk Linux: /usr/lib/android-sdk/ndk ``` -------------------------------- ### Install Debian/Ubuntu Dependencies Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Install required packages for building ALVR on Debian 12, Ubuntu 20.04, or Pop!_OS 20.04. ```bash sudo apt install pulseaudio-utils build-essential pkg-config libclang-dev libssl-dev libasound2-dev libjack-dev libgtk-3-dev libvulkan-dev libunwind-dev gcc yasm nasm curl libx264-dev libx265-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libdrm-dev libva-dev libvulkan-dev vulkan-headers libpipewire-0.3-dev libspa-0.3-dev git ``` -------------------------------- ### Install Steam Native Runtime (Arch Linux) Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Install the `steam-native-runtime` package from the multilib repository on Arch Linux to obtain required libraries. ```bash sudo pacman -S steam-native-runtime ``` -------------------------------- ### Install VAAPI Drivers on Arch Linux Source: https://github.com/alvr-org/alvr/wiki/Linux-Troubleshooting For Arch Linux users, install 'vulkan-radeon' and follow the Hardware Video Acceleration guide. Avoid using VAAPI for Nvidia. ```bash sudo pacman -Syu vulkan-radeon ``` -------------------------------- ### Install Android SDK Platform-Tools and NDK on Debian/Ubuntu Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Installs necessary Android development tools, including platform-tools and NDK, on Debian-based systems. Ensure the 'non-free' repository is enabled. ```bash sudo apt install android-sdk-platform-tools-common sdkmanager google-android-ndk-r26b-installer ``` -------------------------------- ### Install Nvidia Drivers and CUDA on Fedora Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Install the necessary Nvidia drivers and CUDA toolkit components for Fedora. ```bash sudo dnf install akmod-nvidia sudo dnf install xorg-x11-drv-nvidia-cuda ``` -------------------------------- ### Setup ALVR Launcher via Flatpak Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak Configure ADB vendor keys and run the ALVR launcher within the Steam Flatpak. Ensure ADB is set up and the device is authorized. ```bash export ADB_VENDOR_KEYS=~/.android/adb.pub flatpak override --user --filesystem=~/.android com.valvesoftware.Steam.Utility.alvr flatpak run --env=ADB_VENDOR_KEYS=$ADB_VENDOR_KEYS --command=alvr_launcher com.valvesoftware.Steam ``` -------------------------------- ### Install Arch Linux Dependencies Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Install necessary packages for building ALVR on Arch Linux. ```bash sudo pacman -S clang curl nasm pkgconf yasm vulkan-headers libva-mesa-driver unzip ffmpeg libpipewire ``` -------------------------------- ### Install VAAPI Drivers on Arch Linux Source: https://github.com/alvr-org/alvr/blob/master/wiki/Linux-Troubleshooting.md Follow these steps to install hardware video acceleration drivers on Arch Linux. Ensure you reboot after installation. Avoid using VAAPI for Nvidia. ```bash sudo pacman -Syu sudo pacman -S libva-mesa-driver mesa-vdpau # For Nvidia, do not use VAAPI. Instead, follow the Arch Wiki page for hardware video acceleration. ``` -------------------------------- ### Initialize and Manage ALVR Client Session (C) Source: https://context7.com/alvr-org/alvr/llms.txt This snippet shows the basic lifecycle of an ALVR client using the C FFI. It includes initialization, setting client capabilities, handling per-frame events, sending tracking and button data, and finally pausing and destroying the session. Ensure proper setup for logging and Android context if applicable. ```c #include "alvr_client_core.h" // --- Initialization --- alvr_initialize_logging(); #ifdef ANDROID alvr_initialize_android_context(java_vm, context); #endif AlvrClientCapabilities caps = { .default_view_width = 1832, .default_view_height = 1920, .max_view_width = 2064, .max_view_height = 2208, .refresh_rates = rates_ptr, // float[] .refresh_rates_count = 4, .foveated_encoding = true, .encoder_high_profile= true, .encoder_10_bits = false, .encoder_av1 = false, .prefer_10bit = false, .preferred_encoding_gamma = 1.0f, .prefer_hdr = false, }; alvr_initialize(caps); alvr_resume(); // --- Per-frame event poll --- AlvrEvent event; while (alvr_poll_event(&event)) { switch (event.tag) { case AlvrEvent_StreamingStarted: printf("Stream: %ux%u @ %.1fHz\n", event.streaming_started.view_width, event.streaming_started.view_height, event.streaming_started.refresh_rate_hint); break; case AlvrEvent_DecoderConfig: // Read config NAL bytes uint64_t sz = alvr_get_decoder_config(NULL); uint8_t *buf = malloc(sz); alvr_get_decoder_config((char *)buf); create_hw_decoder(event.decoder_config.codec, buf, sz); free(buf); break; case AlvrEvent_Haptics: fire_haptics(event.haptics.device_id, event.haptics.duration_s, event.haptics.frequency, event.haptics.amplitude); break; } } // --- Send tracking data --- AlvrDeviceMotion motions[2] = { head_motion, left_ctrl_motion }; AlvrPose *hand_skeletons[2] = { left_26_poses, right_26_poses }; alvr_send_tracking( timestamp_ns, motions, 2, (const AlvrPose **)hand_skeletons, combined_gaze_quat // or NULL ); // --- Controller buttons --- uint64_t trigger_id = alvr_path_string_to_id("/user/hand/right/input/trigger/value"); AlvrButtonValue val = { .Scalar = 0.95f }; alvr_send_button(trigger_id, val); // --- Battery --- alvr_send_battery(head_device_id, 0.72f, /*is_plugged=*/false); // --- Video pipeline reporting --- AlvrViewParams view_params[2]; alvr_report_compositor_start(target_timestamp_ns, view_params); // ... render with view_params ... alvr_report_submit(target_timestamp_ns, vsync_queue_ns); alvr_report_frame_decoded(target_timestamp_ns); // --- Cleanup --- alvr_pause(); alvr_destroy(); ``` -------------------------------- ### Install Nvidia CUDA Toolkit Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Installs the Nvidia CUDA toolkit after configuring the repository. This command also disables the default nvidia-driver module to prevent conflicts. ```bash sudo dnf clean all sudo dnf module disable nvidia-driver sudo dnf -y install cuda export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}} ``` -------------------------------- ### Rust Path Example Source: https://github.com/alvr-org/alvr/blob/master/CONTRIBUTING.md When both directory and file paths are used in the same context, suffix directories with `_dir` and files with `_path`. Suffix file names with `_fname`. ```rust let myfile_string = "./file.txt"; let myfile = Path::new(my_file_string); ``` -------------------------------- ### ALVR Server-Side Control Plane Setup (Rust) Source: https://context7.com/alvr-org/alvr/llms.txt This Rust snippet demonstrates setting up a server-side control plane listener using `ProtoControlSocket`. It shows how to accept a client connection, exchange initial handshake messages, and then split the socket into typed sender and receiver pairs for sending and receiving control packets like keep-alives and battery status. ```rust use alvr_sockets::{ ProtoControlSocket, PeerType, get_server_listener, KEEPALIVE_INTERVAL, KEEPALIVE_TIMEOUT, }; use alvr_packets::{ServerControlPacket, ClientControlPacket}; use std::time::Duration; // SERVER SIDE let listener = get_server_listener(Duration::from_secs(1))?; // Block until a client connects let (mut proto, client_ip) = ProtoControlSocket::connect_to( Duration::from_secs(5), PeerType::Server(&listener), )?; println!("Client connected from {client_ip}"); // Exchange handshake packets (any serde type) proto.send(&"hello from server")?; let greeting: String = proto.recv(Duration::from_secs(2))?; // Split into typed sender / receiver pair let (mut sender, mut receiver) = proto.split::(KEEPALIVE_TIMEOUT)?; // Send a control packet sender.send(&ServerControlPacket::KeepAlive)?; // Receive a control packet (non-blocking with timeout) match receiver.recv(KEEPALIVE_INTERVAL) { Ok(ClientControlPacket::RequestIdr) => { /* request IDR from encoder */ }, Ok(ClientControlPacket::Battery(info)) => { println!("Battery {:.0}%", info.gauge_value * 100.0); } Ok(ClientControlPacket::Buttons(entries)) => { /* process input */ }, _ => {} } ``` -------------------------------- ### Run ALVR Launcher via Flatpak Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak Use this command to launch the ALVR dashboard when an xdg shortcut is not set up. Ensure Steam Flatpak is installed. ```sh flatpak run --command=alvr_launcher com.valvesoftware.Steam ``` -------------------------------- ### Install ALVR Icon Resource Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak Installs the ALVR icon for the application launcher using the xdg-icon-resource utility. This ensures the ALVR dashboard has a proper icon associated with it. ```sh xdg-icon-resource install --size 256 alvr_icon.png application-alvr-launcher ``` -------------------------------- ### Verify Nvidia Driver Installation Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Check if the Nvidia driver module is loaded and accessible. ```bash modinfo -F version nvidia ``` -------------------------------- ### Install VAAPI Drivers on Fedora Source: https://github.com/alvr-org/alvr/wiki/Linux-Troubleshooting For Fedora users experiencing 'Failed to create VAAPI encoder' errors, switch from 'mesa-va-drivers' to 'mesa-va-drivers-freeworld'. ```bash sudo dnf swap mesa-va-drivers mesa-va-drivers-freeworld ``` -------------------------------- ### Check for Missing Libraries Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source After installing Steam Native Runtime, run this command to identify any missing ELF libraries. ```bash cd ~/.steam/root/ubuntu12_32 file * | grep ELF | cut -d: -f1 | LD_LIBRARY_PATH=. xargs ldd | grep 'not found' | sort | uniq ``` -------------------------------- ### ALVR Web Server REST API Examples Source: https://context7.com/alvr-org/alvr/llms.txt Interact with the ALVR server using `curl` commands. Requires the `X-ALVR` header. Supports session management, client connections, IDR insertion, recording control, driver registration, and version retrieval. ```bash # Retrieve the current session configuration (also fires a Session event over WebSocket) curl -H "X-ALVR: 1" http://localhost:8082/api/session/ ``` ```bash # Patch individual settings values by JSON path curl -X POST -H "X-ALVR: 1" -H "Content-Type: application/json" \ http://localhost:8082/api/session/values \ -d '[{"path":["video","preferred_fps"],"value":90}]' ``` ```bash # Trust / update a connected client curl -X POST -H "X-ALVR: 1" -H "Content-Type: application/json" \ http://localhost:8082/api/session/client-connections \ -d '["quest3.local", {"Trust": null}]' ``` ```bash # Request an IDR (force keyframe) on the video stream curl -X POST -H "X-ALVR: 1" http://localhost:8082/api/insert-idr ``` ```bash # Start / stop video recording to disk curl -X POST -H "X-ALVR: 1" http://localhost:8082/api/recording/start ``` ```bash curl -X POST -H "X-ALVR: 1" http://localhost:8082/api/recording/stop ``` ```bash # Register the ALVR OpenVR driver curl -X POST -H "X-ALVR: 1" http://localhost:8082/api/drivers/register-alvr ``` ```bash # Get the running server version curl -H "X-ALVR: 1" http://localhost:8082/api/version ``` ```bash # → "21.0.0-dev13" ``` -------------------------------- ### Prepare Build Dependencies Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Run this command in the project root to prepare necessary dependencies for building. ```bash cargo xtask prepare-deps --platform android ``` -------------------------------- ### Initialize and Use StreamSocket for Client Source: https://context7.com/alvr-org/alvr/llms.txt Demonstrates setting up a client-side `StreamSocket` to listen for and connect to a server, subscribe to video and statistics streams, and process incoming data. ```rust use alvr_sockets::{StreamSocketBuilder, StreamSocket}; use alvr_packets::{TRACKING, VIDEO, HAPTICS, STATISTICS}; use alvr_session::{SocketProtocol, SocketBufferConfig}; use std::time::Duration; use std::net::IpAddr; // CLIENT: listen for the server's stream socket let builder = StreamSocketBuilder::listen_for_server( Duration::from_secs(5), /*port=*/9944, SocketProtocol::Udp, None, // DSCP TOS SocketBufferConfig::default(), )?; let server_ip: IpAddr = "192.168.1.10".parse().unwrap(); let mut socket: StreamSocket = builder.accept_from_server( server_ip, 9944, /*max_packet_size=*/65507, Duration::from_secs(5) )?; // Subscribe to streams before the recv loop let mut video_rx = socket.subscribe_to_stream::(VIDEO, 3); let mut stats_tx: alvr_sockets::StreamSender = socket.request_stream(STATISTICS); // Receive loop: route shards to their streams loop { socket.recv().ok(); // dispatches incoming shards to subscribed queues // Non-blocking pull from the video stream if let Ok(data) = video_rx.recv(Duration::ZERO) { if data.had_packet_loss() { eprintln!("Packet loss detected"); } let (header, payload) = data.get()?; decode_video_frame(header.timestamp, header.is_idr, payload); } } // Send client statistics back to the server stats_tx.send_header(&alvr_packets::ClientStatistics { target_timestamp: Duration::from_millis(33), total_pipeline_latency: Duration::from_millis(40), ..Default::default() })?; ``` -------------------------------- ### Modify dependencies.rs for CUDA and GCC Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Updates the dependencies.rs file to specify the correct CUDA installation path and the GCC version for compilation. Adjust paths and versions according to your system setup. ```rust change ```cuda``` -> ```cuda-12.3``` (or whatever version you have) replace that line with ```--nvccflags=\"-ccbin /home/linuxbrew/.linuxbrew/bin/g++-11 -gencode arch=compute_52,code=sm_52 -O2\"``` (Change homebrew path if needed, default is used) ``` -------------------------------- ### SteamVR Launch Options for Flatpak Steam Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak Configure these custom launch options in Steam for the Flatpak version of Steam to ensure SteamVR starts correctly. Adjust the path if your Steam installation differs. ```sh ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command% ``` -------------------------------- ### SteamVR Launch Options for Native Steam Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak Configure these custom launch options in Steam for the native Linux version of Steam to ensure SteamVR starts correctly. Adjust the path if your Steam installation differs. ```sh ~/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command% ``` -------------------------------- ### Build and Run ALVR Client Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Build and run the ALVR client directly from the source directory. Ensure the headset is connected via USB with the screen on. ```bash cd alvr/client_openxr cargo apk run ``` -------------------------------- ### Install Homebrew Package Manager Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Installs the Homebrew package manager on your system. This is required for installing specific software versions like gcc@11. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Prepare ALVR Dependencies Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Download and prepare necessary dependencies for the ALVR streamer build. Use `--gpl` on Windows for FFmpeg bundling and `--no-nvidia` on Linux for AMD GPUs. ```bash cargo xtask prepare-deps --platform [your platform] [--gpl] [--no-nvidia] ``` -------------------------------- ### Prepend QT_QPA_PLATFORM for wlroots Compositors Source: https://github.com/alvr-org/alvr/wiki/Linux-Troubleshooting If using Hyprland, Sway, or other wlroots-based Wayland compositors, prepend this to your SteamVR launch options to resolve potential Qt platform issues. ```bash QT_QPA_PLATFORM=xcb ``` -------------------------------- ### Accept Android SDK Licenses (Windows) Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Navigate to the Android SDK tools directory and run this command to accept necessary licenses for building on Windows. ```shell cd "%ANDROID_SDK_ROOT%\tools\bin" sdkmanager.bat --licenses ``` -------------------------------- ### Accept Android SDK Licenses (Linux) Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Navigate to your Android SDK directory and run this command to accept necessary licenses for building on Linux. ```shell cd ~/AndroidSDK sdkmanager --licenses ``` -------------------------------- ### Build ALVR Client (Release) Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Compile the ALVR client application in release mode. The output APK will be located in `build/alvr_client_quest`. ```bash cargo xtask build-client --release ``` -------------------------------- ### Install GCC 11 using Homebrew Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Installs GCC version 11 using Homebrew. This is a requirement for CUDA compatibility, as newer GCC versions may not be supported. ```bash brew install gcc@11 ``` -------------------------------- ### Fix PipeWire Errors for System Flatpak Steam Installation Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak This command grants the Steam Flatpak permission to access the PipeWire socket, which is necessary for audio functionality. Run this in the terminal for a system-wide Flatpak installation. ```sh flatpak override --filesystem="xdg-run/pipewire-0" com.valvesoftware.Steam ``` -------------------------------- ### Initialize and Use BitrateManager Source: https://context7.com/alvr-org/alvr/llms.txt Instantiate BitrateManager to track frame data and network stats. Report frame events and network statistics to adapt bitrate. Query for updated encoder parameters when needed. ```rust use alvr_server_core::bitrate::{BitrateManager, DynamicEncoderParams}; use alvr_session::{BitrateConfig, BitrateMode}; use std::time::Duration; let mut mgr = BitrateManager::new(/*max_history_size=*/256, /*initial_framerate=*/90.0); // Called at each frame present event let adapt_config = alvr_common::settings_schema::Switch::Disabled; mgr.report_frame_present(&adapt_config); // Called when the encoder finishes a frame mgr.report_frame_encoded( /*timestamp=*/Duration::from_millis(11), /*encoder_latency=*/Duration::from_millis(3), /*size_bytes=*/45_000, ); // Called when network stats arrive from the client let mode = BitrateMode::ConstantMbps(100); mgr.report_frame_latencies( &mode, Duration::from_millis(11), /*network_latency=*/Duration::from_millis(5), /*decoder_latency=*/Duration::from_millis(2), ); // Query the recommended encoder parameters (returns None if no update needed) let config = BitrateConfig { mode: BitrateMode::ConstantMbps(100), adapt_to_framerate: alvr_common::settings_schema::Switch::Disabled, }; if let Some((params, directives)) = mgr.get_encoder_params(&config) { println!("Bitrate: {:.1} Mbps, FPS: {:.1}", params.bitrate_bps / 1e6, params.framerate); if let Some(net_cap) = directives.network_latency_limiter_bps { println!("Network latency limiter active: {:.1} Mbps", net_cap / 1e6); } } ``` -------------------------------- ### Fix PipeWire Errors for User Flatpak Steam Installation Source: https://github.com/alvr-org/alvr/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak This command grants the Steam Flatpak permission to access the PipeWire socket, which is necessary for audio functionality. Run this in the terminal for a user-level Flatpak installation. ```sh flatpak override --user --filesystem="xdg-run/pipewire-0" com.valvesoftware.Steam ``` -------------------------------- ### Create libffi Symlink (Linux 64-bit) Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Create a symbolic link to fix missing libffi dependencies on 64-bit systems. This is a workaround and requires testing. ```bash cd /lib/x86_64-linux-gnu ln -s libffi.so.7 libffi.so.6 ``` -------------------------------- ### Update Fedora System Source: https://github.com/alvr-org/alvr/wiki/Building-From-Source Update all packages on Fedora before installing Nvidia drivers and CUDA. ```bash sudo dnf update -y ``` -------------------------------- ### Manage ALVR Session Configuration Source: https://context7.com/alvr-org/alvr/llms.txt Shows how to load default session settings, merge updates from a JSON patch, materialize active settings, trust new clients, and serialize the configuration for persistence. ```rust use alvr_session::{SessionConfig, Settings}; use serde_json as json; // Load defaults let mut session = SessionConfig::default(); println!("Server version: {}", session.server_version); // Partially update from a JSON blob (e.g. user edited config file) let patch = json::json!({ "session_settings": { "video": { "preferred_fps": 120.0 }, "headset": { "gui_collapsed": false, "controllers": { "enabled": false } } } }); session.merge_from_json(&patch).unwrap(); // Materialize the active Settings (resolves Switch/Optional branches) let settings: Settings = session.to_settings(); assert_eq!(settings.video.preferred_fps, 120.0); assert!(settings.headset.controllers.as_option().is_none()); // Trust a new client use alvr_packets::ClientConnectionsAction; use std::collections::HashMap; session.client_connections.insert( "quest3.local".to_string(), alvr_session::ClientConnectionConfig { display_name: "Quest 3".into(), current_ip: None, manual_ips: Default::default(), trusted: true, connection_state: alvr_common::ConnectionState::Disconnected, }, ); // Serialize to JSON for persistence let serialized = json::to_string_pretty(&session).unwrap(); std::fs::write("/etc/alvr/session.json", serialized).unwrap(); ``` -------------------------------- ### Rust Prefer Get Over Indexing Source: https://github.com/alvr-org/alvr/blob/master/CONTRIBUTING.md Prefer `.get()` to index a collection rather than `[]`, unless extremely certain it will never index out of bounds. ```rust .get(); ```