use of org.jivesoftware.smackx.muc.packet.Destroy in project Smack by igniterealtime.
the class MUCParserUtils method parseDestroy.
public static Destroy parseDestroy(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
final EntityBareJid jid = ParserUtils.getBareJidAttribute(parser);
String reason = null;
outerloop: while (true) {
int eventType = parser.next();
switch(eventType) {
case XmlPullParser.START_TAG:
final String name = parser.getName();
switch(name) {
case "reason":
reason = parser.nextText();
break;
}
break;
case XmlPullParser.END_TAG:
if (initialDepth == parser.getDepth()) {
break outerloop;
}
break;
}
}
return new Destroy(jid, reason);
}
use of org.jivesoftware.smackx.muc.packet.Destroy 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 the reason for the room destruction.
* @param alternateJID the 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
* appropiate error messages to end-users.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws InterruptedException
*/
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);
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
// Reset occupant information.
occupantsMap.clear();
nickname = null;
joined = false;
userHasLeft();
}
Aggregations