Finish Rust implementation of ClientState
This commit is contained in:
@ -55,6 +55,10 @@ impl CoreDump for CoreDumper {
|
|||||||
Ok(crate::coredump::WebrtcStats::default())
|
Ok(crate::coredump::WebrtcStats::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_client_state(&self) -> Result<crate::coredump::ClientState> {
|
||||||
|
Ok(crate::coredump::ClientState::default())
|
||||||
|
}
|
||||||
|
|
||||||
async fn screenshot(&self) -> Result<String> {
|
async fn screenshot(&self) -> Result<String> {
|
||||||
// Take a screenshot of the engine.
|
// Take a screenshot of the engine.
|
||||||
todo!()
|
todo!()
|
||||||
|
|||||||
@ -66,6 +66,7 @@ pub trait CoreDump: Clone {
|
|||||||
let webrtc_stats = self.get_webrtc_stats().await?;
|
let webrtc_stats = self.get_webrtc_stats().await?;
|
||||||
let os = self.os().await?;
|
let os = self.os().await?;
|
||||||
let screenshot_url = self.upload_screenshot().await?;
|
let screenshot_url = self.upload_screenshot().await?;
|
||||||
|
let client_state = self.get_client_state().await?;
|
||||||
|
|
||||||
let mut app_info = AppInfo {
|
let mut app_info = AppInfo {
|
||||||
version: self.version()?,
|
version: self.version()?,
|
||||||
@ -76,6 +77,7 @@ pub trait CoreDump: Clone {
|
|||||||
webrtc_stats,
|
webrtc_stats,
|
||||||
github_issue_url: None,
|
github_issue_url: None,
|
||||||
pool: self.pool()?,
|
pool: self.pool()?,
|
||||||
|
client_state,
|
||||||
};
|
};
|
||||||
app_info.set_github_issue_url(&screenshot_url)?;
|
app_info.set_github_issue_url(&screenshot_url)?;
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,9 @@ extern "C" {
|
|||||||
|
|
||||||
#[wasm_bindgen(method, js_name = screenshot, catch)]
|
#[wasm_bindgen(method, js_name = screenshot, catch)]
|
||||||
fn screenshot(this: &CoreDumpManager) -> Result<js_sys::Promise, js_sys::Error>;
|
fn screenshot(this: &CoreDumpManager) -> Result<js_sys::Promise, js_sys::Error>;
|
||||||
|
|
||||||
|
#[wasm_bindgen(method, js_name = getWebrtcStats, catch)]
|
||||||
|
fn get_client_state(this: &CoreDumpManager) -> Result<js_sys::Promise, js_sys::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -140,4 +143,25 @@ impl CoreDump for CoreDumper {
|
|||||||
|
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_client_state(&self) -> Result<crate::coredump::ClientState> {
|
||||||
|
let promise = self
|
||||||
|
.manager
|
||||||
|
.get_client_state()
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to get promise from get client state: {:?}", e))?;
|
||||||
|
|
||||||
|
let value = JsFuture::from(promise)
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to get response from client state: {:?}", e))?;
|
||||||
|
|
||||||
|
// Parse the value as a string.
|
||||||
|
let s = value
|
||||||
|
.as_string()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("Failed to get string from response from client stat: `{:?}`", value))?;
|
||||||
|
|
||||||
|
let client_state: crate::coredump::ClientState =
|
||||||
|
serde_json::from_str(&s).map_err(|e| anyhow::anyhow!("Failed to parse client state: {:?}", e))?;
|
||||||
|
|
||||||
|
Ok(client_state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user