Particularly useful when adding the ability to catch buddy requests.
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Packet;
/**
-
Filters for packets of a specific type of Presence (e.g. SUBSCRIBE).
-
@see org.jivesoftware.smack.packet.Presence.Type
-
@author Michael Ossareh
*/
public class PresenceTypeFilter implements PacketFilter {
private final Presence.Type type;
/**
-
Creates a new message type filter using the specified message type.
-
@param type the presence type.
*/
public PresenceTypeFilter(Presence.Type type) {
this.type = type;
}
public boolean accept(Packet packet) {
if (!(packet instanceof Presence)) {
return false;
}
else {
return ((Presence) packet).getType().equals(this.type);
}
}
}