[DEV] set the connection removed when disconnect

This commit is contained in:
Edouard DUPIN 2021-06-01 00:10:48 +02:00
parent 9ee9354568
commit 8128f19f7b

View File

@ -3,7 +3,7 @@ package org.atriasoft.esignal;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
public class Connection implements AutoCloseable { public class Connection implements AutoCloseable {
protected final WeakReference<ConnectionRemoveInterface> connection; protected WeakReference<ConnectionRemoveInterface> connection;
public void disconnect() { public void disconnect() {
close(); close();
@ -27,5 +27,17 @@ public class Connection implements AutoCloseable {
return; return;
} }
tmp.disconnect(this); tmp.disconnect(this);
this.connection = null;
}
public boolean isConnected() {
if (this.connection == null) {
return false;
}
ConnectionRemoveInterface tmp = this.connection.get();
if (tmp == null) {
return false;
}
return true;
} }
} }