Make sure the connection control doesn't emit any events after disconnect is called
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@555 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
6acf9d6078
commit
af128b65b5
1 changed files with 14 additions and 5 deletions
|
@ -157,14 +157,16 @@ public class ConnectionControl implements IConnectionControl {
|
|||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
final Connection theConnection = connection;
|
||||
connection = null;
|
||||
|
||||
connectedEvent = new Event();
|
||||
connectionFailedEvent = new Event1<LoginError>();
|
||||
run(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
connection = null;
|
||||
if (theConnection != null) {
|
||||
theConnection.disconnect();
|
||||
}
|
||||
ConnectionControl.this.run(STOP_ACTION);
|
||||
}
|
||||
|
@ -502,6 +504,10 @@ public class ConnectionControl implements IConnectionControl {
|
|||
}
|
||||
|
||||
private void processPacket(Packet packet) {
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DefaultPacketExtension extension = (DefaultPacketExtension) packet
|
||||
.getExtension(ELEMENT_NAME, NAMESPACE);
|
||||
|
||||
|
@ -702,12 +708,15 @@ public class ConnectionControl implements IConnectionControl {
|
|||
private abstract class SendRunner implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (connection != null) {
|
||||
// For thread safety
|
||||
Connection theConnection = connection;
|
||||
|
||||
if (theConnection != null) {
|
||||
DefaultPacketExtension extension = createJRummikubExtension();
|
||||
addData(extension);
|
||||
Message message = createMessage(extension);
|
||||
modifyMessage(message);
|
||||
connection.sendPacket(message);
|
||||
theConnection.sendPacket(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue