Skip to content

Commit

Permalink
README: Complete client example
Browse files Browse the repository at this point in the history
  • Loading branch information
arlo-phoenix committed Nov 18, 2023
1 parent d7a99c5 commit eb45e9a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To add a new method to the server you just need to append the list of methods in

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

```go
```py
extends DBusServerNode

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

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

```go
var err=request("Divide", _on_request_finished, 50, 10)
```py
extends DBusClientNode


func _on_request_finished(response: DBusMessage):
assert(response) #will be None if request failed
print(response.read_single(TYPE_FLOAT)) #read response one by one

func _ready() -> void:
open()
var err=request("Divide", _on_request_finished, 50, 10)
assert(err == OK)
```

`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.
Expand Down

0 comments on commit eb45e9a

Please sign in to comment.