Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show these 'fully qualified paths' for bevy_remote's rpc #16944

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3686,6 +3686,18 @@ description = "Demonstrates volumetric fog and lighting"
category = "3D Rendering"
wasm = true

[[example]]
name = "list_all_paths"
path = "examples/remote/list_all_paths.rs"
doc-scrape-examples = true
required-features = ["bevy_remote"]

[package.metadata.example.list_all_paths]
name = "list_all_paths"
description = "A simple command line client using BRQ that will list all the fully-qualified paths that the you need to know."
category = "Remote Protocol"
wasm = false

[[example]]
name = "client"
path = "examples/remote/client.rs"
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ Example | Description
Example | Description
--- | ---
[client](../examples/remote/client.rs) | A simple command line client that can control Bevy apps via the BRP
[list_all_paths](../examples/remote/list_all_paths.rs) | A simple command line client using BRQ that will list all the fully-qualified paths that the you need to know.
[server](../examples/remote/server.rs) | A Bevy app that you can connect to with the BRP and edit

## Scene
Expand Down
29 changes: 29 additions & 0 deletions examples/remote/list_all_paths.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Example to get all the fully-qualified paths that the `./client.rs` example is talking about.

use anyhow::Result as AnyhowResult;
use bevy::remote::{
builtin_methods::BRP_LIST_METHOD, http::DEFAULT_ADDR, http::DEFAULT_PORT, BrpRequest,
};

/// The application entry point.
fn main() -> AnyhowResult<()> {
// Create the URL. We're going to need it to issue the HTTP request.
let host_part = format!("{}:{}", DEFAULT_ADDR, DEFAULT_PORT);
let url = format!("http://{}/", host_part);

// If you pass no params, you'll be able to see all the optinos for arguments you can pass to the `./client.rs` remote example.
alphastrata marked this conversation as resolved.
Show resolved Hide resolved
let req = BrpRequest {
jsonrpc: "2.0".to_string(),
method: BRP_LIST_METHOD.to_string(),
id: Some(ureq::json!(1)),
params: None,
};

let res = ureq::post(&url)
.send_json(req)?
.into_json::<serde_json::Value>()?;

println!("{:#}", res);

Ok(())
}
Loading