예제 #1
0
func (h handler) GotConnection(server dbus.Server, conn *dbus.Conn) {
	conn.Export(h.f, "/com/github/guelfey/Demo/PeerServer", "com.github.guelfey.PeerServer")
	conn.Export(introspect.Introspectable(intro), "/com/github/guelfey/Demo/PeerServer",
		"org.freedesktop.DBus.Introspectable")
	if err := conn.ServerAuth(nil, server.Uuid()); err != nil {
		panic(err)
	}
}
예제 #2
0
func main() {
	conn, err := dbus.SessionBus()
	if err != nil {
		panic(err)
	}
	reply, err := conn.RequestName("com.github.guelfey.Demo",
		dbus.NameFlagDoNotQueue)
	if err != nil {
		panic(err)
	}
	if reply != dbus.RequestNameReplyPrimaryOwner {
		fmt.Fprintln(os.Stderr, "name already taken")
		os.Exit(1)
	}
	f := foo("Bar!")
	conn.Export(f, "/com/github/guelfey/Demo", "com.github.guelfey.Demo")
	conn.Export(introspect.Introspectable(intro), "/com/github/guelfey/Demo",
		"org.freedesktop.DBus.Introspectable")
	fmt.Println("Listening on com.github.guelfey.Demo / /com/github/guelfey/Demo ...")
	select {}
}