Skip to content

Commit

Permalink
examples: Add client to partner server
Browse files Browse the repository at this point in the history
With the server example running, the client example may be run to connect to its Demo service and call the Foo function.
  • Loading branch information
ianmjones authored and jsouthworth committed Oct 26, 2021
1 parent 836e65c commit cdbe383
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions _examples/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"os"

"github.com/godbus/dbus/v5"
)

func main() {
conn, err := dbus.ConnectSessionBus()
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to connect to session bus:", err)
os.Exit(1)
}
defer conn.Close()

var s string
obj := conn.Object("com.github.guelfey.Demo", "/com/github/guelfey/Demo")
err = obj.Call("com.github.guelfey.Demo.Foo", 0).Store(&s)
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to call Foo function (is the server example running?):", err)
os.Exit(1)
}

fmt.Println("Result from calling Foo function on com.github.guelfey.Demo interface:")
fmt.Println(s)
}

0 comments on commit cdbe383

Please sign in to comment.