mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Fix the MUC join presence response filter
Error responses do not contain the '110' status. Therefore we have to filter for them via the stanza id and the from address.
This commit is contained in:
parent
6cfdf2bc6f
commit
68cecf2eee
1 changed files with 14 additions and 3 deletions
|
@ -43,7 +43,10 @@ import org.jivesoftware.smack.filter.FromMatchesFilter;
|
|||
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
||||
import org.jivesoftware.smack.filter.MessageWithSubjectFilter;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
import org.jivesoftware.smack.filter.PresenceTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaIdFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.ToMatchesFilter;
|
||||
|
@ -327,9 +330,17 @@ public class MultiUserChat {
|
|||
messageCollector = connection.createStanzaCollector(fromRoomGroupchatFilter);
|
||||
|
||||
// Wait for a presence packet back from the server.
|
||||
// Use a bare JID filter, since the room may rewrite the nickname.
|
||||
StanzaFilter responseFilter = new AndFilter(FromMatchesFilter.createBare(getRoom()), new StanzaTypeFilter(
|
||||
Presence.class), MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF);
|
||||
// @formatter:off
|
||||
StanzaFilter responseFilter = new AndFilter(StanzaTypeFilter.PRESENCE,
|
||||
new OrFilter(
|
||||
// We use a bare JID filter for positive responses, since the MUC service/room may rewrite the nickname.
|
||||
new AndFilter(FromMatchesFilter.createBare(getRoom()), MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF),
|
||||
// In case there is an error reply, we match on an error presence with the same stanza id and from the full
|
||||
// JID we send the join presence to.
|
||||
new AndFilter(FromMatchesFilter.createFull(joinPresence.getTo()), new StanzaIdFilter(joinPresence), PresenceTypeFilter.ERROR)
|
||||
)
|
||||
);
|
||||
// @formatter:on
|
||||
Presence presence;
|
||||
try {
|
||||
presence = connection.createStanzaCollectorAndSend(responseFilter, joinPresence).nextResultOrThrow(conf.getTimeout());
|
||||
|
|
Loading…
Reference in a new issue