 # @private
 asyncLimit = 16
 
+# @private
+namespace = 'chatservice'
 
 # @private
 initState = (redis, state, values, cb) ->

        initState @redis, @makeDBListName('blacklist'), blacklist, fn
      , (fn) =>
        unless whitelistOnly then return fn()
        @redis.hset "#{@prefix}_whitelistmodes", @name, whitelistOnly, fn
    ] , @withTE cb




  # @private
  getUser : (name, cb) ->
    @redis.sismember @makeDBHashName('usersOnline'), name, @withTE cb, (data) =>
      if data then return cb null, user, true
      @redis.sismember @makeDBHashName('users'), name, @withTE cb, (data) =>
        unless data
          return cb @errorBuilder.makeError 'noUser', name
        cb null, user, false

  # @private
  loginUser : (name, socket, cb) ->
    @redis.sismember @makeDBHashName('usersOnline'), name, @withTE cb, (data) =>
      if data
        user = new @server.User name
        user.registerSocket socket, (error) -> cb error, user
      else
        @redis.sismember @makeDBHashName('users'), name, @withTE cb, (data) =>
          user = new @server.User name
          async.parallel [
            (fn) =>
              @redis.sadd @makeDBHashName('users'), name, fn
            (fn) =>
              @redis.sadd @makeDBHashName('usersOnline'), name, fn
          ], @withTE cb, ->
            user.registerSocket socket, cb

  # @private
  logoutUser : (name, cb) ->
    @redis.sismember @makeDBHashName('usersOnline'), name, @withTE cb, (data) =>
      unless data
        return cb @errorBuilder.makeError 'noUserOnline', name
      @redis.srem @makeDBHashName('usersOnline'), name, @withTE cb

  # @private
  addUser : (name, cb = (->), state = null) ->
    @redis.sismember @makeDBHashName('users'), name, @withTE cb, (data) =>
      if data
        return cb @errorBuilder.makeError 'userExists', name
      user = new @server.User name
      @redis.sadd @makeDBHashName('users'), name, @withTE cb, ->
        if state
          user.initState state, cb
        else
