1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01:00

Cancel opened collectors. SMACK-145

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2344 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2004-07-16 20:46:16 +00:00 committed by gdombiak
parent 2b41ad0ccf
commit d53f0e9492
5 changed files with 39 additions and 0 deletions

View file

@ -208,6 +208,8 @@ public class AccountManager {
PacketCollector collector = connection.createPacketCollector(filter); PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg); connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from server."); throw new XMPPException("No response from server.");
} }
@ -235,6 +237,8 @@ public class AccountManager {
PacketCollector collector = connection.createPacketCollector(filter); PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg); connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from server."); throw new XMPPException("No response from server.");
} }
@ -267,6 +271,8 @@ public class AccountManager {
PacketCollector collector = connection.createPacketCollector(filter); PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg); connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from server."); throw new XMPPException("No response from server.");
} }
@ -288,6 +294,8 @@ public class AccountManager {
PacketCollector collector = connection.createPacketCollector(filter); PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg); connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from server."); throw new XMPPException("No response from server.");
} }

View file

@ -285,4 +285,14 @@ public class Chat {
public void addMessageListener(PacketListener listener) { public void addMessageListener(PacketListener listener) {
connection.addPacketListener(listener, messageFilter); connection.addPacketListener(listener, messageFilter);
} }
public void finalize() throws Throwable {
super.finalize();
try {
if (messageCollector != null) {
messageCollector.cancel();
}
}
catch (Exception e) {}
}
} }

View file

@ -188,6 +188,7 @@ public class GroupChat {
connection.sendPacket(joinPresence); connection.sendPacket(joinPresence);
// Wait up to a certain number of seconds for a reply. // Wait up to a certain number of seconds for a reply.
Presence presence = (Presence)response.nextResult(timeout); Presence presence = (Presence)response.nextResult(timeout);
response.cancel();
if (presence == null) { if (presence == null) {
throw new XMPPException("No response from server."); throw new XMPPException("No response from server.");
} }
@ -364,4 +365,14 @@ public class GroupChat {
public void addMessageListener(PacketListener listener) { public void addMessageListener(PacketListener listener) {
connection.addPacketListener(listener, messageFilter); connection.addPacketListener(listener, messageFilter);
} }
public void finalize() throws Throwable {
super.finalize();
try {
if (messageCollector != null) {
messageCollector.cancel();
}
}
catch (Exception e) {}
}
} }

View file

@ -220,6 +220,8 @@ public class PrivateDataManager {
// Wait up to five seconds for a response from the server. // Wait up to five seconds for a response from the server.
IQ response = (IQ)collector.nextResult(5000); IQ response = (IQ)collector.nextResult(5000);
// Stop queuing results
collector.cancel();
if (response == null) { if (response == null) {
throw new XMPPException("No response from the server."); throw new XMPPException("No response from the server.");
} }
@ -264,6 +266,8 @@ public class PrivateDataManager {
// Wait up to five seconds for a response from the server. // Wait up to five seconds for a response from the server.
IQ response = (IQ)collector.nextResult(5000); IQ response = (IQ)collector.nextResult(5000);
// Stop queuing results
collector.cancel();
if (response == null) { if (response == null) {
throw new XMPPException("No response from the server."); throw new XMPPException("No response from the server.");
} }

View file

@ -310,6 +310,8 @@ public class ServiceDiscoveryManager {
// Wait up to 5 seconds for a result. // Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from the server."); throw new XMPPException("No response from the server.");
} }
@ -355,6 +357,8 @@ public class ServiceDiscoveryManager {
// Wait up to 5 seconds for a result. // Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from the server."); throw new XMPPException("No response from the server.");
} }
@ -386,6 +390,8 @@ public class ServiceDiscoveryManager {
// Wait up to 5 seconds for a result. // Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) { if (result == null) {
throw new XMPPException("No response from the server."); throw new XMPPException("No response from the server.");
} }