diff options
| author | WerWolv <werwolv98@gmail.com> | 2022-03-31 16:09:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-31 16:09:56 +0200 |
| commit | 4caa8deb22f65677b158b836e011833792ffc9f0 (patch) | |
| tree | 72ac493acb211276c617897d9b0bb2a1cc1b33ae | |
| parent | 93fe5a7893925d0b1f726987dc58ed03f644b23d (diff) | |
| download | decky-loader-4caa8deb22f65677b158b836e011833792ffc9f0.tar.gz decky-loader-4caa8deb22f65677b158b836e011833792ffc9f0.zip | |
sys: Added comments
| -rw-r--r-- | src/main.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 6d35cdf2..36143ccc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,6 +63,7 @@ struct DebuggerCommand { params: DebuggerCommandParams } +/// Downloads all content from a website async fn get_web_content(url: Uri) -> TokioResult<Vec<WebContent>> { let client = Client::new(); let response = client.get(url).await?; @@ -73,6 +74,7 @@ async fn get_web_content(url: Uri) -> TokioResult<Vec<WebContent>> { Ok(serde_json::from_str(data.as_str())?) } +/// Loads plugins fn load_plugins() -> String { let paths = fs::read_dir("./plugins"); if let Ok(paths) = paths { @@ -99,15 +101,13 @@ fn load_plugins() -> String { #[tokio::main] async fn main() -> TokioResult<()> { + // If CEF Debugging is enabled, it will be accessible through port 8080 let url = "http://127.0.0.1:8080/json".parse::<hyper::Uri>().unwrap(); + // Load all available tabs that can be debugged let contents = get_web_content(url).await?; - println!("Available Content:"); - for content in &contents { - println!(" {}", content.title); - } - + // Find QuickAccess tab (sidebar menu) and get the debugger websocket interface url let mut quick_access_debug_url: Option<String> = None; for content in &contents { if content.title == "QuickAccess" { @@ -117,8 +117,10 @@ async fn main() -> TokioResult<()> { if let Some(url) = quick_access_debug_url { + // Connect to debugger websocket let (mut socket, _) = tungstenite::connect(url)?; + // Create a inject command to send to the debugger let command = DebuggerCommand { id: 1, method: String::from("Runtime.evaluate"), @@ -128,10 +130,11 @@ async fn main() -> TokioResult<()> { } }; + // Send command to debugger socket.write_message(Message::Text(serde_json::to_string(&command)?))?; + // Print response let response = socket.read_message()?; - println!("{}", response); socket.close(None)?; @@ -142,4 +145,4 @@ async fn main() -> TokioResult<()> { Ok(()) -}
\ No newline at end of file +} |
