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:
parent
e5c6c9bdf8
commit
717090d272
39 changed files with 443 additions and 306 deletions
|
@ -74,9 +74,9 @@ public class AgentRoster {
|
|||
presenceMap = new HashMap<String, Map<String, Presence>>();
|
||||
// Listen for any roster packets.
|
||||
PacketFilter rosterFilter = new PacketTypeFilter(AgentStatusRequest.class);
|
||||
connection.addPacketListener(new AgentStatusListener(), rosterFilter);
|
||||
connection.addAsyncPacketListener(new AgentStatusListener(), rosterFilter);
|
||||
// Listen for any presence packets.
|
||||
connection.addPacketListener(new PresencePacketListener(),
|
||||
connection.addAsyncPacketListener(new PresencePacketListener(),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
|
||||
// Send request for roster.
|
||||
|
|
|
@ -157,7 +157,7 @@ public class AgentSession {
|
|||
}
|
||||
}
|
||||
};
|
||||
connection.addPacketListener(packetListener, filter);
|
||||
connection.addAsyncPacketListener(packetListener, filter);
|
||||
// Create the agent associated to this session
|
||||
agent = new Agent(connection, workgroupJID);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class AgentSession {
|
|||
* packet listeners that were added by this agent session will be removed.
|
||||
*/
|
||||
public void close() {
|
||||
connection.removePacketListener(packetListener);
|
||||
connection.removeAsyncPacketListener(packetListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -142,7 +142,7 @@ public class Workgroup {
|
|||
// Register a packet listener for all the messages sent to this client.
|
||||
PacketFilter typeFilter = new PacketTypeFilter(Message.class);
|
||||
|
||||
connection.addPacketListener(new PacketListener() {
|
||||
connection.addAsyncPacketListener(new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
handlePacket(packet);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class MessageEventManager extends Manager {
|
|||
private MessageEventManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
// Listens for all message event packets and fire the proper message event listeners.
|
||||
connection.addPacketListener(new PacketListener() {
|
||||
connection.addAsyncPacketListener(new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
Message message = (Message) packet;
|
||||
MessageEvent messageEvent =
|
||||
|
|
|
@ -85,7 +85,7 @@ public class RosterExchangeManager {
|
|||
fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries());
|
||||
}
|
||||
};
|
||||
connection.addPacketListener(packetListener, PACKET_FILTER);
|
||||
connection.addAsyncPacketListener(packetListener, PACKET_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue