mirror of
https://github.com/RfidResearchGroup/RFIDtools.git
synced 2026-05-12 11:19:59 -07:00
Communication Adapter bug fixed.
This commit is contained in:
@@ -43,7 +43,8 @@ public class PM3FlasherMainActivity extends BaseActivity implements DevCallback<
|
||||
control.register(this);
|
||||
|
||||
// start communication forward!
|
||||
LocalComBridgeAdapter.getInstance().startServer();
|
||||
LocalComBridgeAdapter.getInstance()
|
||||
.startServer(LocalComBridgeAdapter.NAMESPACE_DEFAULT);
|
||||
|
||||
initViews();
|
||||
initActions();
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class DeviceChecker implements Serializable, Closeable {
|
||||
LocalComBridgeAdapter.getInstance()
|
||||
.setInputStream(communication.getInput())
|
||||
.setOutputStream(communication.getOutput())
|
||||
.startServer();
|
||||
.startServer(LocalComBridgeAdapter.NAMESPACE_DEFAULT);
|
||||
if (!checkDevice()) {
|
||||
// if check failed, we must to close device!
|
||||
LocalComBridgeAdapter.getInstance().stopClient();
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class LocalComBridgeAdapter implements Serializable {
|
||||
* */
|
||||
|
||||
// The namespace of the LocalServerSocket
|
||||
public static final String NAMESPACE = "DXL.COM.ASL";
|
||||
public static final String NAMESPACE_DEFAULT = "DXL.COM.ASL";
|
||||
// The tag of the log.
|
||||
private final String LOG_TAG = "LocalComBridgeAdapter";
|
||||
// 本地套接字服务!
|
||||
@@ -188,13 +188,13 @@ public final class LocalComBridgeAdapter implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalComBridgeAdapter startServer() {
|
||||
public LocalComBridgeAdapter startServer(String namespace) {
|
||||
synchronized (LOCK) {
|
||||
if (!listenAccept) {
|
||||
listenAccept = true;
|
||||
try {
|
||||
if (serverSocket == null) {
|
||||
serverSocket = new LocalServerSocket(NAMESPACE);
|
||||
serverSocket = new LocalServerSocket(namespace);
|
||||
}
|
||||
// 创建一个客户端连接线程
|
||||
new ConServerThread().start();
|
||||
@@ -208,7 +208,7 @@ public final class LocalComBridgeAdapter implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void stopServer() {
|
||||
public LocalComBridgeAdapter stopServer() {
|
||||
synchronized (LOCK) {
|
||||
listenAccept = false;
|
||||
if (serverSocket != null) {
|
||||
@@ -221,9 +221,10 @@ public final class LocalComBridgeAdapter implements Serializable {
|
||||
}
|
||||
Log.w(LOG_TAG, "LocalComBridgeAdapter server stop!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void stopClient() {
|
||||
public LocalComBridgeAdapter stopClient() {
|
||||
synchronized (LOCK) {
|
||||
isHasClient = false;
|
||||
try {
|
||||
@@ -238,5 +239,6 @@ public final class LocalComBridgeAdapter implements Serializable {
|
||||
}
|
||||
Log.d(LOG_TAG, "LocalComBridgeAdapter client stop!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user