     .then -> Promise.resolve()
 
   # @private
-  disconnect : (reason, params) ->
-    id = params.id || null
+  disconnect : (reason, {id}) ->
     @removeSocketFromServer id
 
   # @private

    .then -> Promise.resolve()

  # @private
  roomDelete : (roomName) ->
    unless @enableRoomsManagement
      error = new ChatServiceError 'notAllowed'
      return Promise.reject error
    @state.getRoom roomName
    .then (room) =>
      room.checkIsOwner @userName
      .then ->
        room.getUsers()
      .then (userNames) =>

      .then -> Promise.resolve()

  # @private
  roomGetAccessList : (roomName, listName, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.getList @userName, listName, bypassPermissions

  # @private
  roomGetOwner : (roomName, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.getOwner @userName, bypassPermissions

  # @private
  roomGetWhitelistMode : (roomName, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.getMode @userName, bypassPermissions

  # @private
  roomHistory : (roomName, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.getRecentMessages @userName, bypassPermissions

  # @private
  roomHistoryLastId : (roomName, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.getMessagesLastId @userName, bypassPermissions

  # @private
  roomHistorySync : (roomName, msgid, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.getMessagesAfterId @userName, msgid, bypassPermissions

  # @private
  roomJoin : (roomName, {id, bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      @joinSocketToRoom id, roomName, bypassPermissions

  # @private
  roomLeave : (roomName, {id, bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      @leaveSocketFromRoom id, room.name, bypassPermissions

  # @private
  roomMessage : (roomName, msg, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      @processMessage msg
      room.message @userName, msg, bypassPermissions
    .then (pmsg) =>
      @transport.sendToChannel roomName, 'roomMessage', roomName, pmsg
      Promise.resolve pmsg.id

  # @private
  roomRemoveFromList : (roomName, listName, values, {bypassPermissions}) ->
    @state.getRoom roomName
    .then (room) =>
      room.removeFromList @userName, listName, values, bypassPermissions
    .then (userNames) =>
      if @enableAccessListsUpdates
        @transport.sendToChannel roomName, 'roomAccessListRemoved',
