本文整理匯總了Golang中github.com/pdf/golifx/common.Subscription類的典型用法代碼示例。如果您正苦於以下問題:Golang Subscription類的具體用法?Golang Subscription怎麽用?Golang Subscription使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Subscription類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CloseSubscription
// CloseSubscription is a callback for handling the closing of subscriptions.
func (p *V2) CloseSubscription(sub *common.Subscription) error {
p.RLock()
_, ok := p.subscriptions[sub.ID()]
p.RUnlock()
if !ok {
return common.ErrNotFound
}
p.Lock()
delete(p.subscriptions, sub.ID())
p.Unlock()
return nil
}
示例2: CloseSubscription
// CloseSubscription is a callback for handling the closing of subscriptions.
func (c *Client) CloseSubscription(sub *common.Subscription) error {
c.RLock()
_, ok := c.subscriptions[sub.ID()]
c.RUnlock()
if !ok {
return common.ErrNotFound
}
c.Lock()
delete(c.subscriptions, sub.ID())
c.Unlock()
return nil
}
示例3: CloseSubscription
// CloseSubscription is a callback for handling the closing of subscriptions.
func (d *Device) CloseSubscription(sub *common.Subscription) error {
d.RLock()
_, ok := d.subscriptions[sub.ID()]
d.RUnlock()
if !ok {
return common.ErrNotFound
}
d.Lock()
delete(d.subscriptions, sub.ID())
d.Unlock()
return nil
}
示例4: CloseSubscription
// CloseSubscription is a callback for handling the closing of subscriptions.
func (g *Group) CloseSubscription(sub *common.Subscription) error {
g.RLock()
_, ok := g.subscriptions[sub.ID()]
g.RUnlock()
if !ok {
return common.ErrNotFound
}
g.Lock()
delete(g.subscriptions, sub.ID())
g.Unlock()
return nil
}
示例5:
var _ = Describe("Golifx", func() {
var (
client *Client
protocolSubscription *common.Subscription
clientSubscription *common.Subscription
timeout = 200 * time.Millisecond
mockProtocol *mocks.Protocol
mockDevice *mocks.Device
mockLight *mocks.Light
mockLocation *mocks.Location
mockGroup *mocks.Group
deviceID = uint64(1234)
deviceUnknownID = uint64(4321)
deviceLabel = `mockDevice`
deviceUnknownLabel = `unknownDevice`
lightID = uint64(5678)
lightLabel = `mockLight`
locationID = `mockLocationID`
locationUnknownID = `unknownLocationID`
locationLabel = `mockLocation`
locationUnknownLabel = `unknownLocation`
groupID = `mockGroupID`
groupUnknownID = `unknownGroupID`
groupLabel = `mockGroup`
groupUnknownLabel = `unknownGroup`
)
It("should send discovery to the protocol on NewClient", func() {