       @directMessagingState.whitelistOnlySet m, cb
 
 
-# Implements socket.io messages to function calls association.
-class User extends DirectMessaging
-
-  # @param server [object] ChatService object
-  # @param name [string] User name
-  constructor : (@server, @username) ->
-    super @server, @username
-    @chatState = @server.chatState
-    @enableUserlistUpdates = @server.enableUserlistUpdates
-    @enableRoomsManagement = @server.enableRoomsManagement
-    @enableDirectMessages = @server.enableDirectMessages
-    state = @server.chatState.userState
-    @userState = new state @server, @username
-
-  # Resets user direct messaging state according to the object.
-  # @param state [object]
-  # @param cb [callback]
-  initState : (state, cb) ->
-    super state, cb
-
-  # @private
-  registerSocket : (socket, cb) ->
-    @userState.socketAdd socket.id, withEH cb, =>
-      for cmd of userCommands
-        @bindCommand socket, cmd, @[cmd]
-      cb null, @
+# @private
+# @mixin
+CommandBinders =
 
   # @private
   wrapCommand : (name, fn) ->

        cb error, data if cb
      cmd args..., ack, socket.id

  # @private
  withRoom : (roomName, fn) ->
    @chatState.getRoom roomName, fn

        return cb @errorBuilder.makeError 'notAllowed'
      cb()


# Implements room messaging with permissions checking.
# @extend RoomHelpers
class Room

  extend @, RoomHelpers

  # @param server [object] ChatService object
  # @param name [string] Room name
  constructor : (@server, @name) ->
    @errorBuilder = @server.errorBuilder
    state = @server.chatState.roomState
    @roomState = new state @server, @name, @server.historyMaxMessages

  # Resets room state according to the object.
  # @param state [object]
  # @param cb [callback]
  initState : (state, cb) ->
    @roomState.initState state, cb

  # @private
  leave : (userName, cb) ->
    @roomState.removeFromList 'userlist', [userName], cb
