mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 14:01:08 +01: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
|
|
@ -215,16 +215,16 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
|
||||
// register bytestream open packet listener
|
||||
this.initiationListener = new InitiationListener(this);
|
||||
this.connection.addPacketListener(this.initiationListener,
|
||||
this.connection.addAsyncPacketListener(this.initiationListener,
|
||||
this.initiationListener.getFilter());
|
||||
|
||||
// register bytestream data packet listener
|
||||
this.dataListener = new DataListener(this);
|
||||
this.connection.addPacketListener(this.dataListener, this.dataListener.getFilter());
|
||||
this.connection.addSyncPacketListener(this.dataListener, this.dataListener.getFilter());
|
||||
|
||||
// register bytestream close packet listener
|
||||
this.closeListener = new CloseListener(this);
|
||||
this.connection.addPacketListener(this.closeListener, this.closeListener.getFilter());
|
||||
this.connection.addSyncPacketListener(this.closeListener, this.closeListener.getFilter());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -548,9 +548,9 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
managers.remove(connection);
|
||||
|
||||
// remove all listeners registered by this manager
|
||||
this.connection.removePacketListener(this.initiationListener);
|
||||
this.connection.removePacketListener(this.dataListener);
|
||||
this.connection.removePacketListener(this.closeListener);
|
||||
this.connection.removeAsyncPacketListener(this.initiationListener);
|
||||
this.connection.removeSyncPacketListener(this.dataListener);
|
||||
this.connection.removeSyncPacketListener(this.closeListener);
|
||||
|
||||
// shutdown threads
|
||||
this.initiationListener.shutdown();
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
public IBBInputStream() {
|
||||
// add data packet listener to connection
|
||||
this.dataPacketListener = getDataPacketListener();
|
||||
connection.addPacketListener(this.dataPacketListener, getDataPacketFilter());
|
||||
connection.addSyncPacketListener(this.dataPacketListener, getDataPacketFilter());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -431,7 +431,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* Invoked if the session is closed.
|
||||
*/
|
||||
private void cleanup() {
|
||||
connection.removePacketListener(this.dataPacketListener);
|
||||
connection.removeSyncPacketListener(this.dataPacketListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
public synchronized void disableService() {
|
||||
|
||||
// remove initiation packet listener
|
||||
this.connection.removePacketListener(this.initiationListener);
|
||||
this.connection.removeAsyncPacketListener(this.initiationListener);
|
||||
|
||||
// shutdown threads
|
||||
this.initiationListener.shutdown();
|
||||
|
|
@ -718,7 +718,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
*/
|
||||
private void activate() {
|
||||
// register bytestream initiation packet listener
|
||||
this.connection.addPacketListener(this.initiationListener,
|
||||
this.connection.addAsyncPacketListener(this.initiationListener,
|
||||
this.initiationListener.getFilter());
|
||||
|
||||
// enable SOCKS5 feature
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue