Skip to content

Commit 58bc8be

Browse files
committed
add send_custom_notification
1 parent e864522 commit 58bc8be

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

plugins/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,15 +700,28 @@ where
700700
pub fn state(&self) -> &S {
701701
&self.state
702702
}
703-
pub fn sender(&self) -> &tokio::sync::mpsc::Sender<serde_json::Value> {
704-
&self.sender
705-
}
706703
}
707704

708705
impl<S> Plugin<S>
709706
where
710707
S: Send + Clone,
711708
{
709+
pub async fn send_custom_notification(
710+
&self,
711+
method: String,
712+
v: serde_json::Value,
713+
) -> Result<(), Error> {
714+
self.sender
715+
.send(json!({
716+
"jsonrpc": "2.0",
717+
"method": method,
718+
"params": {method: v},
719+
}))
720+
.await
721+
.context("sending custom notification")?;
722+
Ok(())
723+
}
724+
712725
/// Wait for plugin shutdown
713726
pub async fn join(&self) -> Result<(), Error> {
714727
self.wait_handle

0 commit comments

Comments
 (0)