private void leave(String reason, EntityBareJid alternateAddress)
    {
        OperationSetBasicTelephonyJabberImpl basicTelephony
            = (OperationSetBasicTelephonyJabberImpl) provider
                .getOperationSet(OperationSetBasicTelephony.class);
        if(basicTelephony != null && this.publishedConference != null)
        {
            ActiveCallsRepositoryJabberImpl activeRepository
                    = basicTelephony.getActiveCallsRepository();
            String callid = publishedConference.getCallId();
            if (callid != null)
            {
                CallJabberImpl call = activeRepository.findCallId(callid);
                for(CallPeerJabberImpl peer : call.getCallPeerList())
                {
                    try
                    {
                        peer.hangup(false, null, null);
                    }
                    catch (NotConnectedException | InterruptedException e)
                    {
                        logger.error("Could not hangup peer " + peer.getAddress(), e);
                    }
                }
            }
        }
        List<CallJabberImpl> tmpConferenceCalls;
        synchronized (chatRoomConferenceCalls)
        {
            tmpConferenceCalls
                = new ArrayList<CallJabberImpl>(chatRoomConferenceCalls);
            chatRoomConferenceCalls.clear();
        }
        for(CallJabberImpl call : tmpConferenceCalls)
        {
            for(CallPeerJabberImpl peer : call.getCallPeerList())
            {
                try
                {
                    peer.hangup(false, null, null);
                }
                catch (NotConnectedException | InterruptedException e)
                {
                    logger.error("Could not hangup peer " + peer.getAddress(), e);
                }
            }
        }
        clearCachedConferenceDescriptionList();
        XMPPConnection connection = this.provider.getConnection();
        try
        {
            // if we are already disconnected
            // leave maybe called from gui when closing chat window
            if(connection != null)
                multiUserChat.leave();
        }
        catch(Throwable e)
        {
            logger.warn("Error occured while leaving, maybe just " +
                "disconnected before leaving", e);
        }
        // FIXME Do we have to do the following when we leave the room?
        Hashtable<Resourcepart, ChatRoomMemberJabberImpl> membersCopy;
        synchronized (members)
        {
            membersCopy = new Hashtable<>(members);
            // Delete the list of members
            members.clear();
        }
        for (ChatRoomMember member : membersCopy.values())
            fireMemberPresenceEvent(
                member,
                ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT,
                "Local user has left the chat room.");
        // connection can be null if we are leaving cause connection failed
        if(connection != null)
        {
            connection.removeAsyncStanzaListener(invitationRejectionListeners);
            if(presenceListener != null)
            {
                connection.removeAsyncStanzaListener(presenceListener);
                presenceListener = null;
            }
        }
        opSetMuc.fireLocalUserPresenceEvent(
            this,
            LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT,
            reason,
            alternateAddress != null ? alternateAddress.toString() : null);
    }
private void leave(String reason, EntityBareJid alternateAddress)
    {
        OperationSetBasicTelephonyJabberImpl basicTelephony
            = (OperationSetBasicTelephonyJabberImpl) provider
                .getOperationSet(OperationSetBasicTelephony.class);
        if(basicTelephony != null && this.publishedConference != null)
        {
            ActiveCallsRepositoryJabberImpl activeRepository
                    = basicTelephony.getActiveCallsRepository();
            String callid = publishedConference.getCallId();
            if (callid != null)
            {
                CallJabberImpl call = activeRepository.findCallId(callid);
                for(CallPeerJabberImpl peer : call.getCallPeerList())
                {
                    try
                    {
                        peer.hangup(false, null, null);
                    }
                    catch (NotConnectedException | InterruptedException e)
                    {
                        logger.error("Could not hangup peer " + peer.getAddress(), e);
                    }
                }
            }
        }
        List<CallJabberImpl> tmpConferenceCalls;
        synchronized (chatRoomConferenceCalls)
        {
            tmpConferenceCalls
                = new ArrayList<CallJabberImpl>(chatRoomConferenceCalls);
            chatRoomConferenceCalls.clear();
        }
        for(CallJabberImpl call : tmpConferenceCalls)
        {
            for(CallPeerJabberImpl peer : call.getCallPeerList())
            {
                try
                {
                    peer.hangup(false, null, null);
                }
                catch (NotConnectedException | InterruptedException e)
                {
                    logger.error("Could not hangup peer " + peer.getAddress(), e);
                }
            }
        }
        clearCachedConferenceDescriptionList();
        XMPPConnection connection = this.provider.getConnection();
        try
        {
           
           
            if(connection != null)
                multiUserChat.leave();
        }
        catch(Throwable e)
        {
            logger.warn("Error occured while leaving, maybe just " +
                "disconnected before leaving", e);
        }
       
        Hashtable<Resourcepart, ChatRoomMemberJabberImpl> membersCopy;
        synchronized (members)
        {
            membersCopy = new Hashtable<>(members);
           
            members.clear();
        }
        for (ChatRoomMember member : membersCopy.values())
            fireMemberPresenceEvent(
                member,
                ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT,
                "Local user has left the chat room.");
       
        if(connection != null)
        {
            connection.removeAsyncStanzaListener(invitationRejectionListeners);
            if(presenceListener != null)
            {
                connection.removeAsyncStanzaListener(presenceListener);
                presenceListener = null;
            }
        }
        opSetMuc.fireLocalUserPresenceEvent(
            this,
            LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT,
            reason,
            alternateAddress != null ? alternateAddress.toString() : null);
    }
private void leave(string reason, entitybarejid alternateaddress) { operationsetbasictelephonyjabberimpl basictelephony = (operationsetbasictelephonyjabberimpl) provider .getoperationset(operationsetbasictelephony.class); if(basictelephony != null && this.publishedconference != null) { activecallsrepositoryjabberimpl activerepository = basictelephony.getactivecallsrepository(); string callid = publishedconference.getcallid(); if (callid != null) { calljabberimpl call = activerepository.findcallid(callid); for(callpeerjabberimpl peer : call.getcallpeerlist()) { try { peer.hangup(false, null, null); } catch (notconnectedexception | interruptedexception e) { logger.error("could not hangup peer " + peer.getaddress(), e); } } } } list<calljabberimpl> tmpconferencecalls; synchronized (chatroomconferencecalls) { tmpconferencecalls = new arraylist<calljabberimpl>(chatroomconferencecalls); chatroomconferencecalls.clear(); } for(calljabberimpl call : tmpconferencecalls) { for(callpeerjabberimpl peer : call.getcallpeerlist()) { try { peer.hangup(false, null, null); } catch (notconnectedexception | interruptedexception e) { logger.error("could not hangup peer " + peer.getaddress(), e); } } } clearcachedconferencedescriptionlist(); xmppconnection connection = this.provider.getconnection(); try { if(connection != null) multiuserchat.leave(); } catch(throwable e) { logger.warn("error occured while leaving, maybe just " + "disconnected before leaving", e); } hashtable<resourcepart, chatroommemberjabberimpl> memberscopy; synchronized (members) { memberscopy = new hashtable<>(members); members.clear(); } for (chatroommember member : memberscopy.values()) firememberpresenceevent( member, chatroommemberpresencechangeevent.member_left, "local user has left the chat room."); if(connection != null) { connection.removeasyncstanzalistener(invitationrejectionlisteners); if(presencelistener != null) { connection.removeasyncstanzalistener(presencelistener); presencelistener = null; } } opsetmuc.firelocaluserpresenceevent( this, localuserchatroompresencechangeevent.local_user_left, reason, alternateaddress != null ? alternateaddress.tostring() : null); }