mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +02:00
Reworked (send|recv)Listeners, ListenerWrapper
instead of rely on ListenerWrapper checking the PacketFilter *and* invoking the PacketListener we now use two for-each loops, where the first filters the PacketListeners that should get invoked and use the second for-each loop to actually invoke the PacketListener. Before, the code was not thread safe if a PacketListener would remove itself from the (send|recv)Listeners. Also make packet(Listener|Filter) in ListenerWrapper final.
This commit is contained in:
parent
03686fbaaf
commit
15d59299a2
2 changed files with 61 additions and 54 deletions
|
@ -23,7 +23,6 @@ import java.util.concurrent.BlockingQueue;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PlainStreamElement;
|
||||
|
@ -251,13 +250,6 @@ public class DummyConnection extends AbstractXMPPConnection {
|
|||
}
|
||||
|
||||
// Deliver the incoming packet to listeners.
|
||||
for (ListenerWrapper listenerWrapper : recvListeners.values()) {
|
||||
try {
|
||||
listenerWrapper.notifyListener(packet);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
notifiyReceivedListeners(packet);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue