   ###
 
   registerSocket : (socket, cb) ->
-    @userState.socketAdd socket, (error) =>
+    @userState.socketAdd socket.id, (error) =>
       if error
         return cb makeServerError @errorBuilder, error
       for own cmd of userCommands

    cmd = wrapCommand @, name, fn
    socket.on name, (idcmd, args...) ->
      cmd socket, idcmd, null, args...

  sendAccessRemoved : (userNames, roomName, cb) ->
    async.eachLimit userNames, asyncLimit

        wrappedError = makeServerError @errorBuilder, error
        return sendResult socket, idcmd, cb, wrappedError
      @userState.roomRemove roomName, (error) =>
        if error
          wrappedError = makeServerError @errorBuilder, error
          return sendResult socket, idcmd, cb, wrappedError
        if @enableUserlistUpdates
          @send roomName, 'roomUserLeave', roomName, @username
        makeClosure = (id) =>
          return (error) =>
            # TODO other sockets errors handling
            if socket.id == id
              sendResult socket, idcmd, cb, error
             @send id, 'roomLeft', roomName
        # TODO lock user state
        @userState.socketsGetAll (error, sockets) =>
          if error
            wrappedError = makeServerError @errorBuilder, error
            return sendResult socket, idcmd, cb, wrappedError
          for id in sockets
            @server.nsp.adapter.del id, roomName, makeClosure id

  roomMessage : (socket, idcmd, cb
  , roomName, msg) ->
