當前位置: 首頁>>代碼示例>>Golang>>正文


Golang common.Subscription類代碼示例

本文整理匯總了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
}
開發者ID:chendo,項目名稱:golifx,代碼行數:14,代碼來源:v2.go

示例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
}
開發者ID:pdf,項目名稱:golifx,代碼行數:14,代碼來源:client.go

示例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
}
開發者ID:pdf,項目名稱:golifx,代碼行數:14,代碼來源:device.go

示例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
}
開發者ID:chendo,項目名稱:golifx,代碼行數:14,代碼來源:group.go

示例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() {
開發者ID:chendo,項目名稱:golifx,代碼行數:31,代碼來源:client_test.go


注:本文中的github.com/pdf/golifx/common.Subscription類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。