mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-27 06:22:07 +01:00
Remove any pending packet listener from the connection. SMACK-48
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2464 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
8c2ea94613
commit
941b9e752f
2 changed files with 16 additions and 0 deletions
|
@ -42,6 +42,7 @@ public class GroupChat {
|
||||||
private String nickname = null;
|
private String nickname = null;
|
||||||
private boolean joined = false;
|
private boolean joined = false;
|
||||||
private List participants = new ArrayList();
|
private List participants = new ArrayList();
|
||||||
|
private List connectionListeners = new ArrayList();
|
||||||
|
|
||||||
private PacketFilter presenceFilter;
|
private PacketFilter presenceFilter;
|
||||||
private PacketFilter messageFilter;
|
private PacketFilter messageFilter;
|
||||||
|
@ -249,6 +250,7 @@ public class GroupChat {
|
||||||
*/
|
*/
|
||||||
public void addParticipantListener(PacketListener listener) {
|
public void addParticipantListener(PacketListener listener) {
|
||||||
connection.addPacketListener(listener, presenceFilter);
|
connection.addPacketListener(listener, presenceFilter);
|
||||||
|
connectionListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,6 +334,7 @@ public class GroupChat {
|
||||||
*/
|
*/
|
||||||
public void addMessageListener(PacketListener listener) {
|
public void addMessageListener(PacketListener listener) {
|
||||||
connection.addPacketListener(listener, messageFilter);
|
connection.addPacketListener(listener, messageFilter);
|
||||||
|
connectionListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finalize() throws Throwable {
|
public void finalize() throws Throwable {
|
||||||
|
@ -340,6 +343,10 @@ public class GroupChat {
|
||||||
if (messageCollector != null) {
|
if (messageCollector != null) {
|
||||||
messageCollector.cancel();
|
messageCollector.cancel();
|
||||||
}
|
}
|
||||||
|
// Remove all the PacketListeners added to the connection by this GroupChat
|
||||||
|
for (Iterator it=connectionListeners.iterator(); it.hasNext();) {
|
||||||
|
connection.removePacketListener((PacketListener) it.next());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
catch (Exception e) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class MultiUserChat {
|
||||||
private PacketFilter declinesFilter;
|
private PacketFilter declinesFilter;
|
||||||
private PacketListener declinesListener;
|
private PacketListener declinesListener;
|
||||||
private PacketCollector messageCollector;
|
private PacketCollector messageCollector;
|
||||||
|
private List connectionListeners = new ArrayList();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
XMPPConnection.addConnectionListener(new ConnectionEstablishedListener() {
|
XMPPConnection.addConnectionListener(new ConnectionEstablishedListener() {
|
||||||
|
@ -1510,6 +1511,7 @@ public class MultiUserChat {
|
||||||
*/
|
*/
|
||||||
public void addParticipantListener(PacketListener listener) {
|
public void addParticipantListener(PacketListener listener) {
|
||||||
connection.addPacketListener(listener, presenceFilter);
|
connection.addPacketListener(listener, presenceFilter);
|
||||||
|
connectionListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1521,6 +1523,7 @@ public class MultiUserChat {
|
||||||
*/
|
*/
|
||||||
public void removeParticipantListener(PacketListener listener) {
|
public void removeParticipantListener(PacketListener listener) {
|
||||||
connection.removePacketListener(listener);
|
connection.removePacketListener(listener);
|
||||||
|
connectionListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1805,6 +1808,7 @@ public class MultiUserChat {
|
||||||
*/
|
*/
|
||||||
public void addMessageListener(PacketListener listener) {
|
public void addMessageListener(PacketListener listener) {
|
||||||
connection.addPacketListener(listener, messageFilter);
|
connection.addPacketListener(listener, messageFilter);
|
||||||
|
connectionListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1816,6 +1820,7 @@ public class MultiUserChat {
|
||||||
*/
|
*/
|
||||||
public void removeMessageListener(PacketListener listener) {
|
public void removeMessageListener(PacketListener listener) {
|
||||||
connection.removePacketListener(listener);
|
connection.removePacketListener(listener);
|
||||||
|
connectionListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2403,6 +2408,10 @@ public class MultiUserChat {
|
||||||
connection.removePacketListener(subjectListener);
|
connection.removePacketListener(subjectListener);
|
||||||
connection.removePacketListener(presenceListener);
|
connection.removePacketListener(presenceListener);
|
||||||
connection.removePacketListener(declinesListener);
|
connection.removePacketListener(declinesListener);
|
||||||
|
// Remove all the PacketListeners added to the connection by this chat
|
||||||
|
for (Iterator it=connectionListeners.iterator(); it.hasNext();) {
|
||||||
|
connection.removePacketListener((PacketListener) it.next());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
catch (Exception e) {}
|
||||||
|
|
Loading…
Reference in a new issue