mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Make MultiUserChat.leave() behave as leaveSync()
and mark leaveSync() as deprecated. Fixes SMACK-848.
This commit is contained in:
parent
a9de8e2f76
commit
e4c31541e0
3 changed files with 21 additions and 23 deletions
|
@ -450,7 +450,12 @@ public class MultiUserChat {
|
|||
return mucCreateConfigFormHandle;
|
||||
}
|
||||
// We need to leave the room since it seems that the room already existed
|
||||
leave();
|
||||
try {
|
||||
leave();
|
||||
}
|
||||
catch (MucNotJoinedException e) {
|
||||
LOGGER.log(Level.INFO, "Unexpected MucNotJoinedException", e);
|
||||
}
|
||||
throw new MissingMucCreationAcknowledgeException();
|
||||
}
|
||||
|
||||
|
@ -684,28 +689,19 @@ public class MultiUserChat {
|
|||
|
||||
/**
|
||||
* Leave the chat room.
|
||||
*
|
||||
* @return the leave presence as reflected by the MUC.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @throws XMPPErrorException
|
||||
* @throws NoResponseException
|
||||
* @throws MucNotJoinedException
|
||||
* @deprecated use {@link #leave()} instead.
|
||||
*/
|
||||
public synchronized void leave() throws NotConnectedException, InterruptedException {
|
||||
// Note that this method is intentionally not guarded by
|
||||
// "if (!joined) return" because it should be always be possible to leave the room in case the instance's
|
||||
// state does not reflect the actual state.
|
||||
|
||||
// Reset occupant information first so that we are assume that we left the room even if sendStanza() would
|
||||
// throw.
|
||||
userHasLeft();
|
||||
|
||||
final EntityFullJid myRoomJid = this.myRoomJid;
|
||||
if (myRoomJid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We leave a room by sending a presence packet where the "to"
|
||||
// field is in the form "roomName@service/nickname"
|
||||
Presence leavePresence = new Presence(Presence.Type.unavailable);
|
||||
leavePresence.setTo(myRoomJid);
|
||||
connection.sendStanza(leavePresence);
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.5.
|
||||
public synchronized Presence leaveSync() throws NotConnectedException, InterruptedException, MucNotJoinedException, NoResponseException, XMPPErrorException {
|
||||
return leave();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -718,7 +714,7 @@ public class MultiUserChat {
|
|||
* @throws NoResponseException
|
||||
* @throws MucNotJoinedException
|
||||
*/
|
||||
public synchronized Presence leaveSync()
|
||||
public synchronized Presence leave()
|
||||
throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException, MucNotJoinedException {
|
||||
// Note that this method is intentionally not guarded by
|
||||
// "if (!joined) return" because it should be always be possible to leave the room in case the instance's
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.jivesoftware.smackx.disco.AbstractNodeInformationProvider;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucNotJoinedException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
|
@ -206,7 +207,8 @@ public final class MultiUserChatManager extends Manager {
|
|||
|
||||
try {
|
||||
muc.leave();
|
||||
} catch (NotConnectedException | InterruptedException e) {
|
||||
} catch (NotConnectedException | InterruptedException | MucNotJoinedException
|
||||
| NoResponseException | XMPPErrorException e) {
|
||||
if (failedCallback != null) {
|
||||
failedCallback.autoJoinFailed(muc, e);
|
||||
} else {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class MultiUserChatIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
muc.join(Resourcepart.from("nick-one"));
|
||||
|
||||
Presence reflectedLeavePresence = muc.leaveSync();
|
||||
Presence reflectedLeavePresence = muc.leave();
|
||||
|
||||
MUCUser mucUser = MUCUser.from(reflectedLeavePresence);
|
||||
assertNotNull(mucUser);
|
||||
|
|
Loading…
Reference in a new issue