[DEV] set the connection removed when disconnect
This commit is contained in:
parent
9ee9354568
commit
8128f19f7b
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user