Search in sources :

Example 21 with NoResponseException

use of org.jivesoftware.smack.SmackException.NoResponseException in project Smack by igniterealtime.

the class MultiUserChat method destroy.

/**
 * Sends a request to the server to destroy the room. The sender of the request
 * should be the room's owner. If the sender of the destroy request is not the room's owner
 * then the server will answer a "Forbidden" error (403).
 *
 * @param reason an optional reason for the room destruction.
 * @param alternateJID an optional JID of an alternate location.
 * @throws XMPPErrorException if an error occurs while trying to destroy the room.
 *      An error can occur which will be wrapped by an XMPPException --
 *      XMPP error code 403. The error code can be used to present more
 *      appropriate error messages to end-users.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 */
public void destroy(String reason, EntityBareJid alternateJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCOwner iq = new MUCOwner();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    // Create the reason for the room destruction
    Destroy destroy = new Destroy(alternateJID, reason);
    iq.setDestroy(destroy);
    try {
        connection.sendIqRequestAndWaitForResponse(iq);
    } catch (XMPPErrorException e) {
        // room was not destroyed and we therefore we also did not leave the room.
        throw e;
    } catch (NoResponseException | NotConnectedException | InterruptedException e) {
        // Reset occupant information.
        userHasLeft();
        throw e;
    }
    // Reset occupant information.
    userHasLeft();
}
Also used : XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) Destroy(org.jivesoftware.smackx.muc.packet.Destroy) MUCOwner(org.jivesoftware.smackx.muc.packet.MUCOwner) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException)

Aggregations

NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)21 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)15 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)14 SmackException (org.jivesoftware.smack.SmackException)7 XMPPException (org.jivesoftware.smack.XMPPException)7 IOException (java.io.IOException)6 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)4 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)3 AccountManager (org.jivesoftware.smackx.iqregister.AccountManager)3 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)3 InputStream (java.io.InputStream)2 KeyManagementException (java.security.KeyManagementException)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 NoSuchProviderException (java.security.NoSuchProviderException)2 UnrecoverableKeyException (java.security.UnrecoverableKeyException)2 CertificateException (java.security.cert.CertificateException)2 AlreadyConnectedException (org.jivesoftware.smack.SmackException.AlreadyConnectedException)2 AlreadyLoggedInException (org.jivesoftware.smack.SmackException.AlreadyLoggedInException)2 ConnectionException (org.jivesoftware.smack.SmackException.ConnectionException)2