From 638465908ecb2c46c1f30768e5d879e7ce619e6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 20 Jan 2023 12:23:36 +0200 Subject: [PATCH] examples: webrtc: sendrecv: rust: Allow providing our ID via the commandline Otherwise it continues to use a random ID as before. Part-of: --- subprojects/gst-examples/webrtc/sendrecv/gst-rust/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-examples/webrtc/sendrecv/gst-rust/src/main.rs b/subprojects/gst-examples/webrtc/sendrecv/gst-rust/src/main.rs index 888f920..daffba7 100644 --- a/subprojects/gst-examples/webrtc/sendrecv/gst-rust/src/main.rs +++ b/subprojects/gst-examples/webrtc/sendrecv/gst-rust/src/main.rs @@ -47,8 +47,12 @@ macro_rules! upgrade_weak { struct Args { #[clap(short, long, default_value = "wss://webrtc.nirbheek.in:8443")] server: String, + /// Peer ID that should be called. If not given then an incoming call is expected. #[clap(short, long)] peer_id: Option, + /// Our ID. If not given then a random ID is created. + #[clap(short, long)] + our_id: Option, } // JSON messages we communicate with @@ -737,7 +741,9 @@ async fn async_main() -> Result<(), anyhow::Error> { println!("connected"); // Say HELLO to the server and see if it replies with HELLO - let our_id = rand::thread_rng().gen_range(10..10_000); + let our_id = args + .our_id + .unwrap_or_else(|| rand::thread_rng().gen_range(10..10_000)); println!("Registering id {} with server", our_id); ws.send(WsMessage::Text(format!("HELLO {}", our_id))) .await?; -- 2.7.4