 
     add_listener: (socket) =>
         if not @_state_listeners[socket.id]?
+            dbg = @dbg("add_listener")
+            dbg("adding #{socket.id}")
             @_state_listeners[socket.id] = socket
             socket.on 'close', () =>
+                dbg("closing #{socket.id} and removing listener")
                 delete @_state_listeners[socket.id]
-            @dbg("add_listener")(socket.id)
 
     _update_state_db: (cb) =>
         dbg = @dbg("_update_state_db")

    opts = defaults opts,
        project_id : required
        cb         : required
    v = project_cache_cb[opts.project_id]
    if v?
        v.push(opts.cb)

            project_id : @project_id
            state      : @_state
            time       : @_state_time
        dbg("send message to each of the #{@_state_listeners.length} listeners that the state has been updated = #{misc.to_safe_str(mesg)}")
        for id, socket of @_state_listeners
            dbg("sending mesg to socket #{id}")
            socket.write_mesg('json', mesg)
