本文整理汇总了Golang中github.com/godbus/dbus.Conn.RequestName方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.RequestName方法的具体用法?Golang Conn.RequestName怎么用?Golang Conn.RequestName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/godbus/dbus.Conn
的用法示例。
在下文中一共展示了Conn.RequestName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
// go func() {
// log.Println(http.ListenAndServe("localhost:6060", nil))
// }()
var err error
var bus *dbus.Conn
bus, err = dbus.SystemBus()
if err != nil {
log.Panic(err)
}
reply, err := bus.RequestName("com.devicehive.bluetooth",
dbus.NameFlagDoNotQueue)
if err != nil {
log.Panic(err)
}
if reply != dbus.RequestNameReplyPrimaryOwner {
log.Fatal("name already taken")
}
w := NewBleDbusWrapper(bus)
bus.Export(w, dbus.ObjectPath("/com/devicehive/bluetooth"), "com.devicehive.bluetooth")
// Introspectable
n := &introspect.Node{
Interfaces: []introspect.Interface{
{
Name: "com.devicehive.bluetooth",
Methods: introspect.Methods(w),
Signals: []introspect.Signal{
introspect.Signal{
Name: "PeripheralDiscovered",
Args: []introspect.Arg{{"id", "s", "out"}, {"name", "s", "out"}, {"rssi", "i", "out"}},
},
introspect.Signal{
Name: "PeripheralConnected",
Args: []introspect.Arg{{"id", "s", "out"}},
},
introspect.Signal{
Name: "PeripheralDisconnected",
Args: []introspect.Arg{{"id", "s", "out"}},
},
introspect.Signal{
Name: "NotificationReceived",
Args: []introspect.Arg{{"mac", "s", "out"}, {"uuid", "s", "out"}, {"value", "s", "out"}},
},
introspect.Signal{
Name: "IndicationReceived",
Args: []introspect.Arg{{"mac", "s", "out"}, {"uuid", "s", "out"}, {"value", "s", "out"}},
},
},
},
},
}
root := &introspect.Node{
Children: []introspect.Node{
{
Name: "com/devicehive/bluetooth",
},
},
}
bus.Export(introspect.NewIntrospectable(n), dbus.ObjectPath("/com/devicehive/bluetooth"), "org.freedesktop.DBus.Introspectable")
bus.Export(introspect.NewIntrospectable(root), "/", "org.freedesktop.DBus.Introspectable") // workaroud for dbus issue #14
select {}
}