本文整理匯總了Golang中github.com/emersion/go-kdeconnect/network.Device.PairRequestSent方法的典型用法代碼示例。如果您正苦於以下問題:Golang Device.PairRequestSent方法的具體用法?Golang Device.PairRequestSent怎麽用?Golang Device.PairRequestSent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/emersion/go-kdeconnect/network.Device
的用法示例。
在下文中一共展示了Device.PairRequestSent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PairDevice
func (e *Engine) PairDevice(device *network.Device) error {
if device.Paired {
return nil
}
if !device.PairRequestSent {
pair := &protocol.Pair{
Pair: true,
}
pub, err := e.config.PrivateKey.PublicKey().Marshal()
if err != nil {
return err
}
pair.PublicKey = string(pub)
err = device.Send(protocol.PairType, pair)
if err != nil {
return err
}
log.Println("Sent pairing request to", device.Name)
device.PairRequestSent = true
}
if device.PairRequestReceived && device.PairRequestSent {
device.Paired = true
log.Println("Device", device.Name, "paired")
if e.getKnownDevice(device) == -1 {
// Add it to the list of known devices
e.config.KnownDevices = append(e.config.KnownDevices, NewKnownDeviceFromDevice(device))
}
select {
case e.Paired <- device:
default:
}
}
return nil
}