Skip to content

Commit a8288c9

Browse files
committed
README: Complete client example
1 parent d7a99c5 commit a8288c9

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ To add a new method to the server you just need to append the list of methods in
2929

3030
Within your script you can later access e.g. the method at index 0 and set the callback to it inside the _ready function.
3131

32-
```go
32+
```py
3333
extends DBusServerNode
3434

3535
func _divide(request: DBusRequest) -> int:
@@ -59,8 +59,18 @@ The Client in this is just directly making calls over DBus and not creating an i
5959

6060
You can set destination, object_path and interface_name inside the editor. To start the client (open the bus) you then call `open`. Afterwards you can send requests to the specified interface
6161

62-
```go
63-
var err=request("Divide", _on_request_finished, 50, 10)
62+
```py
63+
extends DBusClientNode
64+
65+
66+
func _on_request_finished(response: DBusMessage):
67+
assert(response) #will be None if request failed
68+
print(response.read_single(TYPE_FLOAT)) #read response one by one
69+
70+
func _ready() -> void:
71+
open()
72+
var err=request("Divide", _on_request_finished, 50, 10)
73+
assert(err == OK)
6474
```
6575

6676
`request` is a vararg method which first takes the method name, then a callback and after that all your input arguments to the method. You don't need to close the client again at the end, since it is automatically freed when it goes out of scope.

0 commit comments

Comments
 (0)