1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 09:09:38 +02:00

Rework incoming packet listeners and Roster

Differentiate between asynchronous and synchronous ones. Asynchronous
are the ones where the invocation order may not be the same as the order
in which the stanzas arrived.

Since it's no longer guaranteed that when a unit test calls

processPacket(stanza)

the stanza will be completely processed when the call returns, it was
necessary to extend the unit tests (mostly Roster and ChatManager) with
a packet listener that waits for his invocation. Since we now also use
LinkedHashMaps as Map for the packet listeners (SMACK-531, SMACK-424),
adding a packet listeners as last also means that it will be called as
last. We exploit this behavior change now in the unit tests.

Rename 'recvListeners' to 'syncRecvListeners' in AbstractXMPPConnection.

Rename 'rosterInitialized' to 'loaded' in Roster.

Add Roster.isLoaded().

Reset 'loaded' to false in
Roster.setOfflinePresencesAndResetLoaded() (was setOfflinePresences()).

Fixes SMACK-583, SMACK-532, SMACK-424
This commit is contained in:
Florian Schmaus 2015-01-05 21:42:35 +01:00
parent e5c6c9bdf8
commit 717090d272
39 changed files with 443 additions and 306 deletions

View file

@ -159,7 +159,7 @@ public class JingleManagerTest extends SmackTestCase {
};
// Start a packet listener for session initiation requests
getConnection(0).addPacketListener(new PacketListener() {
getConnection(0).addAsyncPacketListener(new PacketListener() {
public void processPacket(final Packet packet) {
System.out.println("Packet detected... ");
incCounter();

View file

@ -461,7 +461,7 @@ public class JingleManager implements JingleSessionListener {
jingleSessionRequestListeners = new ArrayList<JingleSessionRequestListener>();
// Start a packet listener for session initiation requests
connection.addPacketListener(new PacketListener() {
connection.addAsyncPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
triggerSessionRequested((Jingle) packet);
}

View file

@ -654,9 +654,9 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
/**
* Remove the packet listener used for processing packet.
*/
protected void removePacketListener() {
protected void removeAsyncPacketListener() {
if (packetListener != null) {
getConnection().removePacketListener(packetListener);
getConnection().removeAsyncPacketListener(packetListener);
LOGGER.fine("JINGLE SESSION: REMOVE PACKET LISTENER");
}
@ -667,7 +667,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
* to any packet that we receive...
*/
protected void updatePacketListener() {
removePacketListener();
removeAsyncPacketListener();
LOGGER.fine("UpdatePacketListener");
@ -728,7 +728,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
}
};
getConnection().addPacketListener(packetListener, packetFilter);
getConnection().addAsyncPacketListener(packetListener, packetFilter);
}
// Listeners
@ -1002,7 +1002,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
contentNegotiator.close();
}
removePacketListener();
removeAsyncPacketListener();
removeConnectionListener();
getConnection().removeConnectionListener(connectionListener);
LOGGER.fine("Negotiation Closed: " + getConnection().getUser() + " " + sid);