Skip to content

Commit 29f39e7

Browse files
committed
Update RPC example to also use rset
1 parent 3ad211b commit 29f39e7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

examples/rpc/src/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl ServerPuppet {
4747
#[method]
4848
fn on_connected_to_server(&mut self, #[base] owner: TRef<Node>) {
4949
owner.rpc("greet_server", &[Variant::new("hello")]);
50+
owner.rset("foo", 42);
5051
}
5152

5253
#[method(rpc = "puppet")]

examples/rpc/src/server.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ const OUT_BANDWIDTH: i64 = 1000;
88

99
#[derive(NativeClass)]
1010
#[inherit(Node)]
11-
pub struct Server;
11+
pub struct Server {
12+
#[property(rpc = "master", set = "Self::set_foo")]
13+
foo: i32,
14+
}
1215

1316
#[methods]
1417
impl Server {
1518
fn new(_owner: &Node) -> Self {
16-
Self
19+
Self { foo: 0 }
1720
}
1821

1922
#[method]
@@ -41,4 +44,10 @@ impl Server {
4144
&[Variant::new("hello")],
4245
);
4346
}
47+
48+
#[method]
49+
fn set_foo(&mut self, #[base] _owner: TRef<Node>, value: i32) {
50+
godot_print!("Client sets foo to: {}", value);
51+
self.foo = value;
52+
}
4453
}

0 commit comments

Comments
 (0)