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();
}
Aggregations