'Called from server side to remove session and inform portal
of this fact.
Args:
session (Session): The Session to disconnect.
reason (str, optional): A motivation for the disconnect.
sync_portal (bool, optional): Sync the disconnect to
Portal side. This should be done unless this was
called by self.portal_disconnect().'

def disconnect(self, session, reason='', sync_portal=True):

    session = self.get(session.sessid)
    if (not session):
        return
    if (hasattr(session, 'player') and session.player):
        nsess = (len(self.sessions_from_player(session.player)) - 1)
        string = 'Logged    out:    {player}    {address}    ({nsessions}    sessions(s)    remaining)'
        string = string.format(player=session.player, address=session.address, nsessions=nsess)
        session.log(string)
    session.at_disconnect()
    sessid = session.sessid
    if ((sessid in self) and (not hasattr(self, '_disconnect_all'))):
        del self[sessid]
    if sync_portal:
        self.server.amp_protocol.send_AdminServer2Portal(session, operation=SDISCONN, reason=reason)
