Esempio n. 1
0
File: v2.go Progetto: chendo/golifx
// 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
}
Esempio n. 2
0
File: device.go Progetto: pdf/golifx
// 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
}
Esempio n. 3
0
File: client.go Progetto: pdf/golifx
// 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
}
Esempio n. 4
0
// 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
}