   constructor: (@address) ->
     @queues = {}
 #    console.log 'broker', @address
-    brokers[@address] = this
 
   ## Broker connection management
   connect: (callback) ->
+    debug 'broker connect'
+    brokers[@address] = this
     return callback null
   disconnect: (callback) ->
+    debug 'broker disconnect'
+    delete brokers[@address]
     return callback null
 
   ## Manipulating queues


interfaces = require './interfaces'
EventEmitter = require('events').EventEmitter


  
  ## Broker connection management
  connect: (callback) ->
    debug 'client connect'
    @broker = brokers[@address]
    return callback null
  disconnect: (callback) ->
    debug 'client disconnect'
    @broker = null
    return callback null

