blob: d298099f1734b8d7e851f29b2776f9b6522490bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
use action_system::{action::ActionContext, action_pool::ActionPool};
use tcp_connection::error::TcpTargetError;
use crate::actions::local_actions::register_set_upstream_vault_action;
fn register_actions(pool: &mut ActionPool) {
// Pool register here
register_set_upstream_vault_action(pool);
}
pub fn client_action_pool() -> ActionPool {
// Create pool
let mut pool = ActionPool::new();
// Register actions
register_actions(&mut pool);
// Add process events
pool.set_on_proc_begin(|ctx| Box::pin(on_proc_begin(ctx)));
// Return
pool
}
async fn on_proc_begin(ctx: &ActionContext) -> Result<(), TcpTargetError> {
// Get instance
let Some(_instance) = ctx.instance() else {
return Err(TcpTargetError::Unsupported(
"Missing ConnectionInstance in current context, this ActionPool does not support this call"
.to_string()));
};
// If it's remote, invoke action at server
if ctx.is_remote() {
// instance.write_text(text)
}
Ok(())
}
|