Send a command and return the message ID immediately without waiting for response.
(
&mut self,
session_id: Option<&str>,
method: &str,
params: Value,
)
| 468 | |
| 469 | /// Send a command and return the message ID immediately without waiting for response. |
| 470 | pub async fn send_raw_no_wait( |
| 471 | &mut self, |
| 472 | session_id: Option<&str>, |
| 473 | method: &str, |
| 474 | params: Value, |
| 475 | ) -> Result<u64> { |
| 476 | let id = self.next_id; |
| 477 | self.next_id += 1; |
| 478 | |
| 479 | let mut msg = json!({"id": id, "method": method}); |
| 480 | if !params.is_null() && params != json!({}) { |
| 481 | msg["params"] = params; |
| 482 | } |
| 483 | if let Some(sid) = session_id { |
| 484 | msg["sessionId"] = json!(sid); |
| 485 | } |
| 486 | |
| 487 | let text = serde_json::to_string(&msg)?; |
| 488 | self.write.send(Message::Text(text)).await?; |
| 489 | Ok(id) |
| 490 | } |
| 491 | |
| 492 | async fn send_raw( |
| 493 | &mut self, |
no test coverage detected