### Install RustPlusApi.Camera Package Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Camera/README.md Use the dotnet CLI to add the RustPlusApi.Camera package to your project. ```bash dotnet add package RustPlusApi.Camera ``` -------------------------------- ### Install RustPlusApi.Fcm.Registration Package Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Fcm.Registration/README.md Use the .NET CLI to add the RustPlusApi.Fcm.Registration package to your project. ```bash dotnet add package RustPlusApi.Fcm.Registration ``` -------------------------------- ### Install RustPlusApi Packages Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/getting-started.md Install the necessary RustPlusApi packages using the .NET CLI. Optional packages for native credentials, camera rendering, and dependency injection are also listed. ```bash dotnet add package RustPlusApi dotnet add package RustPlusApi.Fcm dotnet add package RustPlusApi.Fcm.Registration # native credentials (optional) dotnet add package RustPlusApi.Camera # camera rendering (optional) dotnet add package RustPlusApi.Extensions.DependencyInjection # DI registration (optional) dotnet add package RustPlusApi.Fcm.Extensions.DependencyInjection # DI registration for FCM (optional) ``` -------------------------------- ### Install DocFX as a Global Tool Source: https://github.com/handys11/rustplusapi/blob/develop/docs/README.md Install DocFX globally using the .NET CLI. Ensure the tools directory is on your PATH. ```bash dotnet tool install --global docfx ``` -------------------------------- ### Docs Site Generation with DocFX Source: https://github.com/handys11/rustplusapi/blob/develop/CLAUDE.md Build and serve the project's documentation site using DocFX. Ensure DocFX is installed globally before running the serve command. ```bash # Docs site (DocFX, needs `dotnet tool install --global docfx`): docfx docs/docfx.json --serve ``` -------------------------------- ### C# Camera Rendering Setup Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/cameras.md Subscribe to a camera feed, initialize a CameraRenderer, and process incoming ray frames to render a PNG image. Ensure the player is disconnected from the server when subscribing. The image sharpens over successive frames as more samples are added. ```csharp using RustPlusApi.Camera; var info = (await rustPlus.SubscribeToCameraAsync("CAM01")).Data!; var renderer = new CameraRenderer(info.Width, info.Height); ustPlus.OnCameraRaysReceived += (_, frame) => { renderer.AddRays(frame); byte[] png = renderer.Render(); // save or display }; ``` -------------------------------- ### Install RustPlusApi Package Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi/README.md Use the dotnet CLI to add the RustPlusApi package to your project. ```bash dotnet add package RustPlusApi ``` -------------------------------- ### Mutation Testing Setup Source: https://github.com/handys11/rustplusapi/blob/develop/CLAUDE.md Configure and run mutation tests using Stryker. Navigate to the unit test project directory and execute the stryker command with the specified configuration file and project. ```bash # Mutation testing (run from the unit-test project directory): cd tests/RustPlusApi.Fcm.UnitTests && dotnet stryker --config-file stryker-config.json --project RustPlusApi.Fcm.csproj ``` -------------------------------- ### Add RustPlusApi.Fcm Package Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Fcm/README.md Installs the RustPlusApi.Fcm package using the .NET CLI. ```bash dotnet add package RustPlusApi.Fcm ``` -------------------------------- ### Connect and Query Server Information Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/getting-started.md Connect to a Rust server using provided credentials and retrieve basic server information such as name and player count. This example demonstrates the basic usage of the RustPlus client. ```csharp using RustPlusApi; using var rustPlus = new RustPlus(new RustPlusConnection(server, port, playerId, playerToken)); await rustPlus.ConnectAsync(); var info = await rustPlus.GetInfoAsync(); if (info.IsSuccess) Console.WriteLine($"{info.Data!.Name} — {info.Data.PlayerCount}/{info.Data.MaxPlayerCount} players"); ``` -------------------------------- ### Add RustPlusApi Packages Source: https://github.com/handys11/rustplusapi/blob/develop/README.md Install the necessary RustPlusApi packages using the .NET CLI. Optional packages for FCM and camera rendering are also listed. ```bash dotnet add package RustPlusApi dotnet add package RustPlusApi.Fcm dotnet add package RustPlusApi.Fcm.Registration # native credentials (optional) dotnet add package RustPlusApi.Camera # camera rendering (optional) ``` -------------------------------- ### Connect to Rust+ Server and Get Info Source: https://github.com/handys11/rustplusapi/blob/develop/docs/index.md Connects to a Rust+ server using provided credentials and retrieves server information. Requires RustPlusApi package. ```csharp using RustPlusApi; using var rustPlus = new RustPlus(new RustPlusConnection(server, port, playerId, playerToken)); await rustPlus.ConnectAsync(); var info = await rustPlus.GetInfoAsync(); if (info.IsSuccess) Console.WriteLine($"{info.Data!.Name} — {info.Data.PlayerCount}/{info.Data.MaxPlayerCount}"); ``` -------------------------------- ### Register Entity for Broadcasts in C# Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/troubleshooting.md Call the corresponding info method once after connecting to ensure entity broadcasts start arriving. This example shows how to register for smart switch events. ```csharp // Register the entity with the server — broadcasts start after this call. await rustPlus.GetSmartSwitchInfoAsync(entityId); ustPlus.OnSmartSwitchTriggered += (_, e) => Console.WriteLine($"Switch {e.Id}: {(e.IsActive ? "on" : "off")}"); ``` -------------------------------- ### Acquire Rust+ Credentials Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/credentials.md Orchestrates the entire credential acquisition flow, including GCM check-in, Firebase installation, FCM registration, Expo token retrieval, Steam login, and Rust Companion device registration. Persists credentials to a file for later use. ```csharp using RustPlusApi.Fcm.Registration; var registration = new FcmRegistration(); // Steps 1–4: GCM check-in → Firebase install → FCM register → Expo token. var credentials = await registration.AcquireCredentialsAsync(); // Steps 5–6: interactive Steam login (launches Chrome) + Rust Companion device registration. await registration.RegisterWithRustPlusAsync(credentials); // Step 7: persist for later runs. CredentialsStore.Save("rustplus.config.json", credentials); // Step 8: pair in game; one await yields the RustPlus constructor args. using var listener = new PairingListener(credentials); ServerPairing pairing = await listener.WaitForServerPairingAsync(); // new RustPlus(new RustPlusConnection(pairing.Ip, pairing.Port, pairing.PlayerId, pairing.PlayerToken)) ``` -------------------------------- ### Build and Serve Documentation Locally Source: https://github.com/handys11/rustplusapi/blob/develop/docs/README.md Build the API metadata and site, then serve it with live preview on localhost. This command regenerates API references if API or XML doc comments change. ```bash docfx docs/docfx.json --serve ``` -------------------------------- ### Acquire Credentials and Register with Rust+ Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Fcm.Registration/README.md This C# snippet demonstrates how to acquire necessary credentials for Rust+ services and then register them. It covers the initial credential acquisition and subsequent registration with the Rust+ platform, saving the credentials for future use. Finally, it sets up a listener for server pairing and establishes a connection to Rust+. ```csharp using RustPlusApi.Fcm.Registration; var registration = new FcmRegistration(); var credentials = await registration.AcquireCredentialsAsync(); // GCM/Firebase/FCM/Expo await registration.RegisterWithRustPlusAsync(credentials); // Steam login + Rust Companion CredentialsStore.Save("rustplus.config.json", credentials); using var listener = new PairingListener(credentials); ServerPairing pairing = await listener.WaitForServerPairingAsync(); // pair in game var rustPlus = new RustPlus(new RustPlusConnection(pairing.Ip, pairing.Port, pairing.PlayerId, pairing.PlayerToken)); ``` -------------------------------- ### Clan Information and Management Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/clan-and-nexus.md Retrieve clan information, set the message of the day, get clan chat messages, and send clan messages. ```APIDOC ## Clan Information and Management ### Description Provides methods to interact with the in-game clan system, including fetching clan details, updating the message of the day, retrieving chat history, and sending messages. ### Methods - `GetClanInfoAsync()`: Retrieves a snapshot of the clan's current information. - `SetClanMotdAsync(string message)`: Sets the clan's message of the day. - `GetClanChatAsync()`: Retrieves the recent clan chat messages. - `SendClanMessageAsync(string message)`: Sends a message to the clan chat. ### ClanInfo Properties - `ClanId` (long): Unique identifier of the clan. - `Name` (string): Display name of the clan. - `Created` (DateTime): UTC timestamp when the clan was created. - `Creator` (ulong): Steam64 ID of the clan creator. - `Motd` (string?): Message of the day, or `null` if not set. - `MotdTimestamp` (DateTime?): UTC timestamp when the MOTD was last changed. - `MotdAuthor` (ulong?): Steam64 ID of the player who last changed the MOTD. - `Logo` (byte[]?): Raw bytes of the clan logo image, or `null`. - `Color` (int?): Clan colour as a packed ARGB integer, or `null`. - `Roles` (IEnumerable?): Roles defined in this clan. - `Members` (IEnumerable?): Current members of the clan. - `Invites` (IEnumerable?): Pending invitations to the clan. - `MaxMemberCount` (int?): Member cap, or `null` if uncapped. - `Score` (long?): Clan score, or `null` if not reported. ### ClanRole Properties - `RoleId` (int): Unique identifier within the clan. - `Rank` (int): Rank order; lower values are higher ranks. - `Name` (string): Display name of the role. - `CanSetMotd` (bool): May set the clan MOTD. - `CanSetLogo` (bool): May set the clan logo. - `CanInvite` (bool): May invite players. - `CanKick` (bool): May kick other members. - `CanPromote` (bool): May promote others. - `CanDemote` (bool): May demote others. - `CanSetPlayerNotes` (bool): May set officer notes on members. - `CanAccessLogs` (bool): May view clan audit logs. - `CanAccessScoreEvents` (bool): May view clan score events. ### ClanMember Properties - `SteamId` (ulong): Steam64 ID of the member. - `RoleId` (int): References `ClanRole.RoleId`. - `Joined` (DateTime): UTC timestamp when the member joined. - `LastSeen` (DateTime): UTC timestamp of last online activity. - `Notes` (string?): Officer notes attached to this member. - `Online` (bool?): `true` if currently online, `null` if not reported. ### ClanInvite Properties - `SteamId` (ulong): Steam64 ID of the invited player. - `Recruiter` (ulong): Steam64 ID of the member who sent the invite. - `Timestamp` (DateTime): UTC timestamp when the invitation was created. ### Events - `OnClanChatReceived`: Fires for each individual clan chat message as it arrives. - `OnClanChanged`: Fires whenever the clan snapshot changes (role assignments, member joins/leaves, MOTD updates, etc.) and carries the full updated `ClanInfo`. ``` -------------------------------- ### Basic Camera Subscription and Rendering Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Camera/README.md This snippet shows how to subscribe to a camera feed, set up a frame handler to render frames into PNGs, and handle keep-alive failures. ```csharp using RustPlusApi.Camera; var response = await CameraController.SubscribeAsync(rustPlus, "CAM01"); if (!response.IsSuccess) return; await using var camera = response.Data!; var renderer = new CameraRenderer(camera.Info.Width, camera.Info.Height); camera.OnFrameReceived += (_, frame) => { renderer.AddRays(frame); byte[] png = renderer.Render(); // save / display }; // One check per device kind: IsAutoTurret / IsDrone / IsPtzCamera / IsStaticCamera. // Turrets: await camera.ShootAsync(); await camera.ReloadAsync(); // PTZ cameras: await camera.ZoomAsync(); // Mouse look / drone movement: await camera.LookAsync(10f, 0f); await camera.MoveAsync(CameraButtons.Forward); // All action helpers are capability-gated: an unsupported action is refused client-side // (RustPlusErrorCode.NotSupported) without sending — the server acks unsupported inputs // with success while ignoring them, and zoom shares FirePrimary with turret fire. // Raised when a renewal fails (e.g. NoPlayer after the camera was destroyed in game): camera.OnKeepAliveFailed += (_, error) => Console.WriteLine($"{error.Code} {error.Message}"); ``` -------------------------------- ### Listen for FCM Notifications Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/getting-started.md Set up a listener for Firebase Cloud Messaging (FCM) notifications from Rust+. This example shows how to load credentials and subscribe to the 'OnAlarmTriggered' event. ```csharp using RustPlusApi.Fcm; using RustPlusApi.Fcm.Registration; var credentials = CredentialsStore.Load("rustplus.config.json"); var listener = new RustPlusFcm(credentials); listener.OnAlarmTriggered += (_, alarm) => Console.WriteLine("Alarm!"); await listener.ConnectAsync(); ``` -------------------------------- ### Using the RustPlus Factory for Multiple Connections Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/dependency-injection.md Shows how to register the RustPlus factory and then use it to create and connect clients at runtime. Clients created by the factory are caller-owned and should be disposed by the caller, preferably using 'await using'. ```csharp services.AddRustPlusFactory(); // later, when the connection is known: var factory = provider.GetRequiredService(); await using var client = factory.Create(connection); await client.ConnectAsync(); ``` -------------------------------- ### Get Nexus Authentication Token Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/clan-and-nexus.md Retrieve Nexus authentication details, including the server ID and player token, which are necessary for servers participating in the Nexus cross-server system. Requires a valid appKey. ```csharp var nexus = await rustPlus.GetNexusAuthAsync(appKey); // Response if (nexus.IsSuccess) Console.WriteLine($"{nexus.Data!.ServerId} / {nexus.Data.PlayerToken}"); ``` -------------------------------- ### Capture Camera Snapshot Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/recipes.md This snippet demonstrates how to subscribe to a camera, receive frames, render a PNG snapshot after accumulating a target number of frames, and save it to a file. It requires the RustPlusApi.Camera NuGet package and proper server connection details. ```csharp using RustPlusApi; using RustPlusApi.Camera; const string ServerIp = "192.0.2.1"; const int ServerPort = 28082; const ulong PlayerId = 76561198000000000UL; const int PlayerToken = -123456789; const string CameraId = "CAM01"; // in-game identifier set on the computer station const int FrameTarget = 10; // accumulate 10 frames before saving using var rustPlus = new RustPlus(new RustPlusConnection(ServerIp, ServerPort, PlayerId, PlayerToken)); await rustPlus.ConnectAsync(); var session = await CameraController.SubscribeAsync(rustPlus, CameraId); if (!session.IsSuccess) { Console.Error.WriteLine($"Subscribe failed: {session.Error?.Code} {session.Error?.Message}"); return; } await using var camera = session.Data!; // DisposeAsync stops the keep-alive and unsubscribes var renderer = new CameraRenderer(camera.Info.Width, camera.Info.Height); var tcs = new TaskCompletionSource(); var frameCount = 0; camera.OnFrameReceived += async (_, frame) => { renderer.AddRays(frame); if (++frameCount < FrameTarget) return; // Enough frames — render and save. var png = renderer.Render(); await File.WriteAllBytesAsync("snapshot.png", png); Console.WriteLine($"Saved snapshot.png ({png.Length:N0} bytes) after {frameCount} frames."); tcs.TrySetResult(true); }; await tcs.Task; // wait until the snapshot is saved ``` -------------------------------- ### Construct and Connect RustPlus Client Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/rustplus-client.md Instantiate the RustPlus client with connection details and establish an asynchronous connection. Ensure you have the correct server IP, companion port, Player ID, and Player Token. ```csharp using var rustPlus = new RustPlus(new RustPlusConnection(server, port, playerId, playerToken, UseFacepunchProxy: false)); await rustPlus.ConnectAsync(); ``` -------------------------------- ### Manage Clan Information and Chat Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/clan-and-nexus.md Retrieve clan details, set the message of the day, get clan chat history, and send clan messages. Ensure the rustPlus client is initialized before use. ```csharp var clan = await rustPlus.GetClanInfoAsync(); // Response if (clan.IsSuccess) { Console.WriteLine(clan.Data!.Name); foreach (var member in clan.Data.Members ?? []) Console.WriteLine($" {member.SteamId} (role {member.RoleId})"); } await rustPlus.SetClanMotdAsync("Welcome to the clan!"); var chat = await rustPlus.GetClanChatAsync(); // Response await rustPlus.SendClanMessageAsync("gg"); ``` -------------------------------- ### Build Documentation Site Source: https://github.com/handys11/rustplusapi/blob/develop/docs/README.md Build the documentation site without serving it. The output will be placed in the gitignored `docs/_site/` directory. ```bash docfx docs/docfx.json ``` -------------------------------- ### Run Mutation Testing for RustPlusApi.Camera Project Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute mutation testing for the RustPlusApi.Camera project. Ensure you are in the correct directory for the solution path to resolve correctly. ```bash cd tests/RustPlusApi.Camera.UnitTests dotnet stryker --config-file stryker-config.json --project RustPlusApi.Camera.csproj ``` -------------------------------- ### Run RustPlus.Camera.ConsoleApp for camera interaction Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/samples.md Enables watching and controlling server cameras. Supports interactive mode with ASCII preview, PNG saving, and PTZ controls. Also includes a headless capture mode for generating render fixtures. ```bash dotnet run --project samples/RustPlus.Camera.ConsoleApp ``` ```bash dotnet run --project samples/RustPlus.Camera.ConsoleApp -- [credentialsPath] capture [outputDir] ``` -------------------------------- ### Build and Test Commands Source: https://github.com/handys11/rustplusapi/blob/develop/AGENTS.md Common dotnet CLI commands for building, testing, and analyzing the RustPlusApi solution. Includes commands for full builds, specific target framework tests, filtering tests, and reporting coverage. ```bash dotnet build # strict: TreatWarningsAsErrors + Roslynator/Sonar/VSTHRD analyzers dotnet test RustPlusApi.sln # both TFMs (net8.0 host → netstandard2.0 build; net10.0 host → net10.0 build) dotnet test RustPlusApi.sln -f net8.0 # netstandard2.0 build only dotnet test RustPlusApi.sln -f net10.0 # net10.0 build only dotnet test RustPlusApi.sln --filter "FullyQualifiedName~ClassName.MethodName" tools/coverage/report.sh # full suite + merged coverage report + CI gate (line 95 / branch 90) dotnet tool restore dotnet jb cleanupcode RustPlusApi.sln --profile="ReformatAndReorder" ``` -------------------------------- ### Build and Test Commands for RustPlusApi Source: https://github.com/handys11/rustplusapi/blob/develop/CLAUDE.md Standard .NET CLI commands for building, testing, and running specific test configurations. Use filters for targeted testing and specify target frameworks (TFMs) as needed. ```bash dotnet build # strict: TreatWarningsAsErrors + latest-all analyzers (Roslynator, Sonar, VSTHRD) dotnet test RustPlusApi.sln # runs every test project on BOTH TFM hosts (net8.0 + net10.0) # Single test class/method (still both TFMs): dotnet test RustPlusApi.sln --filter "FullyQualifiedName~ClassName.MethodName" # One TFM only (net8.0 host = exercises the netstandard2.0 build): dotnet test RustPlusApi.sln -f net8.0 dotnet test RustPlusApi.sln -f net10.0 ``` -------------------------------- ### Run RustPlus.ConsoleApp for server query and control Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/samples.md Provides an interactive menu to query and control server information, team, clan, and electricity features. Requires credentials to be set up, typically by copying credentials.sample.json to credentials.json and filling in details from the Register app. ```bash # Copy credentials.sample.json to credentials.json and fill in the values # printed by the Register app (ip / port / playerId / playerToken), then: dotnet run --project samples/RustPlus.ConsoleApp # or pass the path explicitly: dotnet run --project samples/RustPlus.ConsoleApp -- /path/to/credentials.json ``` -------------------------------- ### Run Full Proto Update Pipeline Source: https://github.com/handys11/rustplusapi/blob/develop/tools/update-proto/README.md Execute the entire pipeline: fetch server, decompile contracts, regenerate proto, and generate a diff. The diff is the primary deliverable for reviewing changes. ```bash cd tools/update-proto ./update-proto.sh ``` -------------------------------- ### Basic RustPlus Client Usage Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi/README.md Connect to a Rust+ server, retrieve server information, and subscribe to smart switch events. Requires server details and player credentials. ```csharp using RustPlusApi; using var rustPlus = new RustPlus(new RustPlusConnection(server, port, playerId, playerToken)); await rustPlus.ConnectAsync(); var info = await rustPlus.GetInfoAsync(); // Response if (info.IsSuccess) Console.WriteLine($"{info.Data!.Name} — {info.Data.PlayerCount} players"); ustPlus.OnSmartSwitchTriggered += (_, e) => { /* react to a smart switch */ }; ``` -------------------------------- ### Subscribe and Control Camera/Turret Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/cameras.md Demonstrates subscribing to a camera, receiving frames, and performing device-specific actions like shooting, reloading, zooming, looking, or moving. ```csharp var response = await CameraController.SubscribeAsync(rustPlus, "TURRET01"); if (!response.IsSuccess) return; await using var turret = response.Data!; turret.OnFrameReceived += (_, frame) => renderer.AddRays(frame); if (turret.IsAutoTurret) // ControlFlags has Reload (turret-only input) { await turret.ShootAsync(); // FirePrimary press + release await turret.ReloadAsync(); // Reload press + release } else { // PTZ cameras only. Cycles the zoom levels and wraps. await turret.ZoomAsync(); } await turret.LookAsync(10f, 0f); // mouse look (Mouse flag) await turret.MoveAsync(CameraButtons.Forward); // drone nudge (Movement flag) ``` -------------------------------- ### Run All Tests Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute all tests across all target frameworks in the solution. ```bash dotnet test RustPlusApi.sln ``` -------------------------------- ### Listen for Server Notifications Source: https://github.com/handys11/rustplusapi/blob/develop/README.md Set up a listener for server pairing notifications using RustPlusFcm. This requires the necessary credentials. ```csharp var listener = new RustPlusFcm(credentials); listener.OnServerPairing += (_, e) => Console.WriteLine($"Paired: {e.Data?.Ip}"); await listener.ConnectAsync(); ``` -------------------------------- ### Register RustPlus API from Configuration Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Extensions.DependencyInjection/README.md Register a RustPlusApi client by binding connection details from application configuration. Assumes configuration keys like Server, Port, PlayerId, PlayerToken, and UseFacepunchProxy are present. ```csharp services.AddRustPlus(configuration.GetSection("Rust")); ``` -------------------------------- ### Run RustPlus Camera Console App Source: https://github.com/handys11/rustplusapi/blob/develop/samples/README.md Launch the dedicated camera application for watching and controlling cameras. It supports interactive mode and headless capture for rendering fixture generation. ```bash dotnet run --project samples/RustPlus.Camera.ConsoleApp # headless capture (render-fixture generation): dotnet run --project samples/RustPlus.Camera.ConsoleApp -- [credentialsPath] capture [outputDir] ``` -------------------------------- ### Run Mutation Testing for RustPlusApi.Extensions.DependencyInjection Project Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute mutation testing for the RustPlusApi.Extensions.DependencyInjection project. Ensure you are in the correct directory for the solution path to resolve correctly. ```bash cd tests/RustPlusApi.Extensions.DependencyInjection.UnitTests dotnet stryker --config-file stryker-config.json --project RustPlusApi.Extensions.DependencyInjection.csproj ``` -------------------------------- ### Using the FCM Factory for Runtime Credentials Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/dependency-injection.md Demonstrates registering the FCM factory and using it to create FCM listeners with credentials obtained at runtime. Similar to the RustPlus factory, these listeners are caller-owned and require explicit disposal. ```csharp // or runtime credentials via the factory (e.g. after FcmRegistration.AcquireCredentialsAsync) services.AddRustPlusFcmFactory(); await using var fcm = provider.GetRequiredService().Create(credentials); ``` -------------------------------- ### Run Mutation Testing for RustPlusApi.Fcm.Registration Project Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute mutation testing for the RustPlusApi.Fcm.Registration project. Ensure you are in the correct directory for the solution path to resolve correctly. ```bash cd tests/RustPlusApi.Fcm.Registration.UnitTests dotnet stryker --config-file stryker-config.json --project RustPlusApi.Fcm.Registration.csproj ``` -------------------------------- ### Fetch Rust Dedicated Server Source: https://github.com/handys11/rustplusapi/blob/develop/tools/update-proto/README.md Download the Rust dedicated server files using SteamCMD. This is the first step in the proto update pipeline. ```bash ./1-fetch-server.sh ``` -------------------------------- ### Run Proto Update Pipeline (Skipping Stages) Source: https://github.com/handys11/rustplusapi/blob/develop/tools/update-proto/README.md Reuse previously fetched server data and decompiled contracts to speed up iteration during development. Useful when only the proto regeneration or diffing needs to be re-run. ```bash SKIP_FETCH=1 SKIP_DECOMPILE=1 ./update-proto.sh ``` -------------------------------- ### RustPlusApi Package Structure Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/introduction.md This diagram illustrates the different packages within the RustPlusApi library and their dependencies. It shows how your .NET application can interact with the core client, FCM listener, credential acquisition module, and camera module. ```mermaid graph LR subgraph Your app A[Your .NET code] end A --> Core["RustPlusApi
(WebSocket client)"] A --> Fcm["RustPlusApi.Fcm
(FCM listener)"] A --> Reg["RustPlusApi.Fcm.Registration
(credential acquisition)"] A --> Cam["RustPlusApi.Camera
(camera sessions + rendering)"] Reg --> Fcm Cam --> Core Core -- "WebSocket :companion port" --> S[(Rust server)] Fcm -- "MCS / FCM" --> G[(Google FCM)] Reg -- "HTTPS" --> X[(Google / Expo / Steam / Facepunch)] ``` -------------------------------- ### Registering a Single RustPlus Client Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/dependency-injection.md Demonstrates three ways to register a single RustPlus client: explicitly with connection details, from configuration, or using a service provider delegate. The registered IRustPlus client is a singleton and disposed by the container. ```csharp // explicit connection services.AddRustPlus(new RustPlusConnection("12.34.56.78", 28082, playerId, playerToken)); // or bound from configuration (keys: Server, Port, PlayerId, PlayerToken, UseFacepunchProxy) services.AddRustPlus(configuration.GetSection("Rust")); // or resolved from the provider services.AddRustPlus(sp => BuildConnection(sp), o => o.RequestTimeout = TimeSpan.FromSeconds(10)); ``` -------------------------------- ### Run Mutation Testing for RustPlusApi.Fcm Project Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute mutation testing for the RustPlusApi.Fcm project. Ensure you are in the correct directory for the solution path to resolve correctly. ```bash cd tests/RustPlusApi.Fcm.UnitTests dotnet stryker --config-file stryker-config.json --project RustPlusApi.Fcm.csproj ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute tests and generate coverage reports. Requires a runsettings file and specifies a results directory. Ensure the coverlet.runsettings file is correctly configured. ```bash dotnet test RustPlusApi.sln \ --settings tests/RustPlusApi.UnitTests/coverlet.runsettings \ --results-directory ./TestResults ``` -------------------------------- ### Generate Coverage Report Summary Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Use the helper script to generate a per-class summary of test coverage. This script highlights classes with coverage below 100% and should only list items documented in the Coverage exclusion list. ```bash tools/coverage/report.sh ``` -------------------------------- ### Build .NET Framework Smoke Test Project Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Use this command to build the .NET Framework smoke test project explicitly. This verifies that the public API surface is reachable from a .NET Framework 4.8 consumer. ```bash dotnet build tests/RustPlusApi.NetFrameworkSmoke/RustPlusApi.NetFrameworkSmoke.csproj ``` -------------------------------- ### Run Mutation Testing for RustPlusApi.Fcm.Extensions.DependencyInjection Project Source: https://github.com/handys11/rustplusapi/blob/develop/docs/development/testing.md Execute mutation testing for the RustPlusApi.Fcm.Extensions.DependencyInjection project. Ensure you are in the correct directory for the solution path to resolve correctly. ```bash cd tests/RustPlusApi.Fcm.Extensions.DependencyInjection.UnitTests dotnet stryker --config-file stryker-config.json --project RustPlusApi.Fcm.Extensions.DependencyInjection.csproj ``` -------------------------------- ### Register Console App for Credentials Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/getting-started.md Use the RustPlus.Register.ConsoleApp sample to obtain FCM credentials by running the .NET project. This process logs you into Steam and links your account with Rust+. ```bash dotnet run --project samples/RustPlus.Register.ConsoleApp ``` -------------------------------- ### Enable Logging with LoggerFactory Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/logging.md Instantiate RustPlus with a LoggerFactory to receive structured diagnostics. This includes connection lifecycle events, dropped frames, and errors. ```csharp using Microsoft.Extensions.Logging; using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); using var rustPlus = new RustPlus( new RustPlusConnection("127.0.0.1", 28082, playerId, playerToken), loggerFactory: loggerFactory); ``` -------------------------------- ### Initialize FCM with Logging Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Fcm/README.md Initializes the RustPlusFcm listener with a LoggerFactory for logging purposes. Requires credentials. ```csharp using Microsoft.Extensions.Logging; using var loggerFactory = LoggerFactory.Create(b => b.AddConsole()); var fcm = new RustPlusFcm(credentials, loggerFactory: loggerFactory); ``` -------------------------------- ### RustPlus Client with Logging Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi/README.md Integrate the RustPlus client with Microsoft's logging framework by passing an ILoggerFactory to the constructor. This routes client diagnostics to your configured logging output. ```csharp using Microsoft.Extensions.Logging; using var loggerFactory = LoggerFactory.Create(b => b.AddConsole()); using var rustPlus = new RustPlus( new RustPlusConnection("127.0.0.1", 28082, 76561198000000000, 123456789), loggerFactory: loggerFactory); ``` -------------------------------- ### Entities (Smart Devices) Methods Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/rustplus-client.md Methods for interacting with smart devices like switches and alarms. ```APIDOC ## GetSmartSwitchInfoAsync ### Description Retrieves the current on/off state of a smart switch. ### Method `GetSmartSwitchInfoAsync(entityId)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the smart switch entity. ### Returns `Response` --- ## GetAlarmInfoAsync ### Description Retrieves the current state of an alarm. This is protocol-level identical to a smart switch. ### Method `GetAlarmInfoAsync(entityId)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the alarm entity. ### Returns `Response` --- ## GetStorageMonitorInfoAsync ### Description Retrieves the item list and protection state of a storage monitor. ### Method `GetStorageMonitorInfoAsync(entityId)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the storage monitor entity. ### Returns `Response` --- ## SetSmartSwitchValueAsync ### Description Sets the value of a smart switch to on (`true`) or off (`false`). The reply is the EntityChanged broadcast. ### Method `SetSmartSwitchValueAsync(entityId, value)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the smart switch entity. - **value** (bool) - Required - `true` to turn on, `false` to turn off. ### Returns `Response` --- ## ToggleSmartSwitchAsync ### Description Reads the current state of a smart switch and then flips it. ### Method `ToggleSmartSwitchAsync(entityId)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the smart switch entity. ### Returns `Response` --- ## StrobeSmartSwitchAsync ### Description Pulses a smart switch to a specified value, waits for a timeout, then reverts. Defaults to 1 second on. ### Method `StrobeSmartSwitchAsync(entityId, timeoutMilliseconds, value)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the smart switch entity. - **timeoutMilliseconds** (int) - Required - The duration in milliseconds to keep the switch in the pulsed state. - **value** (bool) - Required - The value to pulse the switch to (`true` for on, `false` for off). ### Returns `Response` --- ## CheckSubscriptionAsync ### Description Checks if you are subscribed to a smart alarm. ### Method `CheckSubscriptionAsync(alarmId)` ### Parameters #### Path Parameters - **alarmId** (int) - Required - The ID of the smart alarm. ### Returns `Response` --- ## SetSubscriptionAsync ### Description Subscribes (`true`) or unsubscribes (`false`) from push notifications for a smart device. ### Method `SetSubscriptionAsync(entityId, doSubscribe)` ### Parameters #### Path Parameters - **entityId** (int) - Required - The ID of the entity to subscribe or unsubscribe from. - **doSubscribe** (bool) - Required - `true` to subscribe, `false` to unsubscribe. ### Returns `Response` ``` -------------------------------- ### Register FCM Credentials with Node CLI Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/troubleshooting.md Use this command as a fallback if the registration flow fails. It requires a `rustplus.config.json` file. ```bash npx @liamcottle/rustplus.js fcm-register ``` -------------------------------- ### Register RustPlusFcm with Credentials Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Fcm.Extensions.DependencyInjection/README.md Registers RustPlusFcm as a singleton service with the provided credentials. The service will be disposed by the container. ```csharp services.AddRustPlusFcm(credentials); ``` -------------------------------- ### Register RustPlus API with a Single Client Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Extensions.DependencyInjection/README.md Register a single, singleton RustPlusApi client. The client is disposed when the service container is disposed. Requires explicit connection details. ```csharp services.AddRustPlus(new RustPlusConnection("12.34.56.78", 28082, playerId, playerToken)); ``` -------------------------------- ### Server & World Methods Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/rustplus-client.md Methods for retrieving general server and world information. ```APIDOC ## GetInfoAsync ### Description Retrieves general server information including name, player counts, map size, and wipe time. ### Method `GetInfoAsync()` ### Returns `Response` --- ## GetTimeAsync ### Description Retrieves the in-game time, sunrise/sunset times, and day-length parameters. ### Method `GetTimeAsync()` ### Returns `Response` --- ## GetMapAsync ### Description Retrieves the server's map image bytes and a list of monuments. This is a large response and should be cached. ### Method `GetMapAsync()` ### Returns `Response` --- ## GetMapMarkersAsync ### Description Retrieves markers for players, cargo ship, patrol helicopter, vending machines, CH-47, and events on the map. ### Method `GetMapMarkersAsync()` ### Returns `Response` ``` -------------------------------- ### Register RustPlusFcm Factory for Runtime Credentials Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Fcm.Extensions.DependencyInjection/README.md Registers a factory for creating RustPlusFcm listeners at runtime, allowing for caller-owned credentials. This is useful when credentials are not known at startup. ```csharp services.AddRustPlusFcmFactory(); await using var fcm = provider.GetRequiredService().Create(credentials); ``` -------------------------------- ### Subscribe, Receive, and Unsubscribe from Camera Data Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/cameras.md Demonstrates subscribing to camera data, handling received frames, and unsubscribing. Ensure you handle the `OnCameraRaysReceived` event to process frame data. ```csharp var info = await rustPlus.SubscribeToCameraAsync("CAM01"); // Response if (!info.IsSuccess) return; ustPlus.OnCameraRaysReceived += (_, frame) => { // frame.VerticalFov, frame.Distance, frame.RayData (RLE depth+material), frame.Entities }; await rustPlus.SendCameraInputAsync(CameraButtons.Forward | CameraButtons.FirePrimary, mouseDeltaX: 0.1f, mouseDeltaY: 0f); await rustPlus.UnsubscribeFromCameraAsync(); ``` -------------------------------- ### Register RustPlus API Factory for Multiple Connections Source: https://github.com/handys11/rustplusapi/blob/develop/src/RustPlusApi.Extensions.DependencyInjection/README.md Register a factory for creating multiple, caller-owned RustPlusApi clients at runtime. This allows for dynamic creation of connections based on provided connection details. ```csharp services.AddRustPlusFactory(); await using var client = provider.GetRequiredService().Create(connection); ``` -------------------------------- ### Code Formatting and Reordering Source: https://github.com/handys11/rustplusapi/blob/develop/CLAUDE.md Utilize ReSharper CLI tools to restore dotnet tools, format code, and reorder members according to project settings. Ensure code is formatted before pushing. ```bash # Formatting + member reordering (ReSharper CLI; whitespace rules from .editorconfig, the # ReformatAndReorder cleanup profile + member layout live in RustPlusApi.sln.DotSettings): dotnet tool restore dotnet jb cleanupcode RustPlusApi.sln --profile="ReformatAndReorder" ``` -------------------------------- ### Load RustPlus Credentials Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/credentials.md Loads RustPlus API credentials from a JSON configuration file and initializes an FCM listener. The legacy rustplus.js format is also supported. ```csharp var credentials = CredentialsStore.Load("rustplus.config.json"); var listener = new RustPlusFcm(credentials); ``` -------------------------------- ### Camera Methods Source: https://github.com/handys11/rustplusapi/blob/develop/docs/articles/rustplus-client.md Methods for interacting with in-game cameras. Note: For more advanced usage, consider `CameraController`. ```APIDOC ## SubscribeToCameraAsync ### Description Starts the `OnCameraRaysReceived` stream for a given camera and returns its width, height, and flags. ### Method `SubscribeToCameraAsync(cameraId)` ### Parameters #### Path Parameters - **cameraId** (int) - Required - The ID of the camera to subscribe to. ### Returns `Response` --- ## SendCameraInputAsync ### Description Sends movement and action input to the currently subscribed camera. ### Method `SendCameraInputAsync(buttons, mouseDeltaX, mouseDeltaY)` ### Parameters #### Path Parameters - **buttons** (int) - Required - Input buttons state. - **mouseDeltaX** (int) - Required - Mouse movement delta on the X-axis. - **mouseDeltaY** (int) - Required - Mouse movement delta on the Y-axis. ### Returns `Response` --- ## UnsubscribeFromCameraAsync ### Description Stops the camera stream. ### Method `UnsubscribeFromCameraAsync()` ### Returns `Response` ```