Hi folks,
Well I’m back at working on DBus again and due to the lack of examples resembling anything in the real world, I’m having a bit of trouble.
When I get introspection to work, I can only get one method to work (if you load another, it overwrites the first. See the server.go under _examples. On the other hand, I can get all my methods to work, but not introspection.
Here’s what I have currently …
type server struct {
id int
}
var dbmethods []introspect.Method
// Foo : test export
func (server) Foo() (string, *dbus.Error) {
return "Bar!", nil
}
// Ping : test
func (server) Ping() (string, *dbus.Error) {
return "Pong!", nil
}
func (dbo dbusobj) registerServerMethods() error {
// Register all methods associated with out server.
var methods []reflect.Method
serverType := reflect.TypeOf(server{})
for i := 0; i < serverType.NumMethod(); i++ {
servmethod := serverType.Method(i)
methods = append(methods, servmethod)
fmt.Println("Server Method:", servmethod.Name)
fmt.Println("Server Method:", servmethod)
methNames[servmethod.Name] = strings.ToLower(servmethod.Name)
err := dbo.Conn.ExportWithMap(server{}, methNames, dbo.Path, dbo.Iface)
if err != nil {
return err
}
// Try to introspect.
// node := &introspect.Node{}
// node.Name = dbo.Iface
// iface := &introspect.Interface{}
// iface.Name = dbo.Iface
// dbmethods = append(dbmethods, introspect.Methods(servmethod)[0])
// iface.Methods = dbmethods
// node.Interfaces = append(node.Interfaces, *iface)
// dbusXMLinsp := introspect.NewIntrospectable(node)
// fmt.Println("Method debug ...") // Debug
// printXML(fmt.Sprint(dbusXMLinsp)) // Debug
// err = dbo.Conn.Export(dbusXMLinsp, dbo.Path, "org.freedesktop.DBus.Introspectable")
// if err != nil {
// return err
// }
}
return nil
}
The commented-out portion is the part that I’m trying to get working. Any suggestions?