diff --git a/plugin/examples/foo_plugin.rs b/plugin/examples/foo_plugin.rs index 536a9e4..c178fc1 100644 --- a/plugin/examples/foo_plugin.rs +++ b/plugin/examples/foo_plugin.rs @@ -27,11 +27,11 @@ impl RPCCommand for HelloRPC { } #[derive(Clone)] -struct OnChannelOpened {} +struct OnShutdown {} -impl RPCCommand for OnChannelOpened { - fn call_void<'c>(&self, _plugin: &mut Plugin, _request: &'c Value) { - _plugin.log(LogLevel::Debug, "A new channel was opened!"); +impl RPCCommand for OnShutdown { + fn call_void<'c>(&self, _: &mut Plugin, _: &'c Value) { + std::process::exit(0); } } @@ -46,11 +46,11 @@ fn main() { .add_opt( "foo", "flag", - Some("false".to_owned()), + Some("false".to_owned()) , "An example of command line option", false, ) - .register_notification("channel_opened", OnChannelOpened {}) + .register_notification("shutdown", OnShutdown {}) .on_init(|plugin: &mut Plugin<_>| -> serde_json::Value { plugin.log(LogLevel::Debug, "Custom init method called"); json!({}) diff --git a/plugin_macros/examples/macros_ex.rs b/plugin_macros/examples/macros_ex.rs index f29dcb4..0c355f7 100644 --- a/plugin_macros/examples/macros_ex.rs +++ b/plugin_macros/examples/macros_ex.rs @@ -35,12 +35,19 @@ fn on_warning(plugin: &mut Plugin, request: &Value) { plugin.log(LogLevel::Info, "received an RPC notification"); } +#[notification(on = "shutdown")] +fn on_shutdown(_: &mut Plugin, _: &Value) { + std::process::exit(0); +} + + fn main() { let plugin = plugin! { state: State::new(), dynamic: true, notification: [ on_warning, + on_shutdown, ], methods: [ foo_rpc,