Skip to content

Commit

Permalink
examples: kill plugins examples
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Feb 14, 2024
1 parent 0e8f3d9 commit 3b21ac5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugin/examples/foo_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ impl RPCCommand<PluginState> for HelloRPC {
}

#[derive(Clone)]
struct OnChannelOpened {}
struct OnShutdown {}

impl RPCCommand<PluginState> for OnChannelOpened {
fn call_void<'c>(&self, _plugin: &mut Plugin<PluginState>, _request: &'c Value) {
_plugin.log(LogLevel::Debug, "A new channel was opened!");
impl RPCCommand<PluginState> for OnShutdown {
fn call_void<'c>(&self, _: &mut Plugin<PluginState>, _: &'c Value) {
std::process::exit(0);
}
}

Expand All @@ -50,7 +50,7 @@ fn main() {
"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!({})
Expand Down
6 changes: 6 additions & 0 deletions plugin_macros/examples/macros_ex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ fn on_warning(plugin: &mut Plugin<State>, request: &Value) {
plugin.log(LogLevel::Info, "received an RPC notification");
}

#[notification(on = "shutdown")]
fn on_shutdown(_: &mut Plugin<State>, _: &Value) {
std::process::exit(0);
}

fn main() {
let plugin = plugin! {
state: State::new(),
dynamic: true,
notification: [
on_warning,
on_shutdown,
],
methods: [
foo_rpc,
Expand Down

0 comments on commit 3b21ac5

Please sign in to comment.