summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-10-13 11:17:00 +0800
committer魏曹先生 <1992414357@qq.com>2025-10-13 11:17:00 +0800
commit860fb317bca61ce66a2c98df933aa666dae0a43f (patch)
tree1aa4440e23b6344097958888aeef231ba4d9e9ba /examples
parent635ded4f6815d738dd9b9b711aa4c7cf302d340b (diff)
feat: Add JSON-based action invocation to ActionPool
- Extend action_gen macro to generate JSON serialization logic - Implement generic action processing using JSON text for type-agnostic calls - Add callback mechanism with action name and arguments in ActionPool - Update client and server registries to use new callback system - Improve action system flexibility at the cost of serialization overhead
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml4
-rw-r--r--examples/src/bin/example_action_system.rs4
2 files changed, 6 insertions, 2 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 3a6cee2..f2442ba 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -19,3 +19,7 @@ action_system = { path = "../crates/system_action" }
# Async & Networking
tokio = { version = "1.46.1", features = ["full"] }
+
+# Serialization
+serde = { version = "1.0.219", features = ["derive"] }
+serde_json = "1.0.140"
diff --git a/examples/src/bin/example_action_system.rs b/examples/src/bin/example_action_system.rs
index a659eb3..c873a2e 100644
--- a/examples/src/bin/example_action_system.rs
+++ b/examples/src/bin/example_action_system.rs
@@ -4,9 +4,9 @@ use tcp_connection::error::TcpTargetError;
#[tokio::main]
async fn main() {
let mut pool = ActionPool::new();
- PrintNameAction::register_to_pool(&mut pool);
+ register_print_name_action(&mut pool);
- PrintNameAction::process_at_pool(&pool, ActionContext::local(), "World".to_string())
+ proc_print_name_action(&pool, ActionContext::local(), "World".to_string())
.await
.unwrap();
}