Example #1
0
func (c *Conn) unbindAll() error {
	c.Lock()
	defer c.Unlock()

	c.channels = make(map[string]*Channel)

	p := proto.NewUnbindProto("")

	_, err := c.request(p.P, proto.Unbind_OK)
	return err
}
Example #2
0
func (c *Conn) unbind(queue string) error {
	c.Lock()
	defer c.Unlock()

	_, ok := c.channels[queue]
	if !ok {
		return fmt.Errorf("queue %s not bind", queue)
	}

	delete(c.channels, queue)

	p := proto.NewUnbindProto(queue)

	rp, err := c.request(p.P, proto.Unbind_OK)
	if err != nil {
		return err
	}

	if rp.Queue() != queue {
		return fmt.Errorf("invalid bind response queue %s", rp.Queue())
	}

	return nil
}