Commit 02260f0d by wjg

1.0.8

parent 0c7fa28d
...@@ -18,8 +18,8 @@ android { ...@@ -18,8 +18,8 @@ android {
applicationId "com.ihaoin.hooloo.device" applicationId "com.ihaoin.hooloo.device"
minSdkVersion 26 minSdkVersion 26
targetSdkVersion 30 targetSdkVersion 30
versionCode 7 versionCode 8
versionName "1.0.7" versionName "1.0.8"
ndk { ndk {
//选择要添加的对应 cpu 类型的 .so 库。 //选择要添加的对应 cpu 类型的 .so 库。
......
...@@ -40,9 +40,22 @@ public class MachineInfoSocket extends Thread { ...@@ -40,9 +40,22 @@ public class MachineInfoSocket extends Thread {
} }
} }
private void reconnect() {
try {
mSocket = IO.socket(Base.NSP_MACHINE);
mSocket.connect();
} catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
private Emitter.Listener onConnect = args -> Utils.i("machine socket connected"); private Emitter.Listener onConnect = args -> Utils.i("machine socket connected");
private Emitter.Listener onDisconnect = args -> Utils.i("machine socket disconnected"); private Emitter.Listener onDisconnect = args -> {
Utils.i("machine socket disconnected");
reconnect();
};
public void close() { public void close() {
try { try {
......
...@@ -41,12 +41,26 @@ public class InteractionSocket extends Thread { ...@@ -41,12 +41,26 @@ public class InteractionSocket extends Thread {
} }
} }
private void reconnect() {
try {
mSocket = IO.socket(Base.NSP_INTERACTION);
mSocket.connect();
} catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
private Emitter.Listener onConnect = args -> { private Emitter.Listener onConnect = args -> {
Utils.i("interaction socket connected"); Utils.i("interaction socket connected");
mSocket.emit("notice", "test", (Ack) ack -> process("notice", ack)); mSocket.emit("notice", "test", (Ack) ack -> process("notice", ack));
}; };
private Emitter.Listener onDisconnect = args -> Utils.i("interaction socket disconnected"); private Emitter.Listener onDisconnect = args -> {
Utils.i("interaction socket disconnected");
reconnect();
};
private Emitter.Listener onReply = args -> { private Emitter.Listener onReply = args -> {
Utils.i("interaction socket reply"); Utils.i("interaction socket reply");
......
...@@ -41,12 +41,25 @@ public class KDSSocket extends Thread { ...@@ -41,12 +41,25 @@ public class KDSSocket extends Thread {
} }
} }
private void reconnect() {
try {
mSocket = IO.socket(Base.NSP_KDS);
mSocket.connect();
} catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
private Emitter.Listener onConnect = args -> { private Emitter.Listener onConnect = args -> {
Utils.i("kds socket connected"); Utils.i("kds socket connected");
mSocket.emit("notice", "test", (Ack) ack -> Utils.i("notice: " + JsonUtils.toString(ack))); mSocket.emit("notice", "test", (Ack) ack -> Utils.i("notice: " + JsonUtils.toString(ack)));
}; };
private Emitter.Listener onDisconnect = args -> Utils.i("kds socket disconnected"); private Emitter.Listener onDisconnect = args -> {
Utils.i("kds socket disconnected");
reconnect();
};
private Emitter.Listener onReply = args -> { private Emitter.Listener onReply = args -> {
Utils.i("kds socket reply"); Utils.i("kds socket reply");
......
...@@ -53,6 +53,19 @@ public class UpdateSocket extends Thread { ...@@ -53,6 +53,19 @@ public class UpdateSocket extends Thread {
} }
} }
private void reconnect() {
try {
mSocket = IO.socket(Base.NSP_UPGRADE);
mSocket.connect();
} catch (Exception e) {
Utils.i(AppConfig.TAG_UPDATE, "连接server失败,错误原因:" + e.getMessage());
if (AppConfig.DEBUG) {
Utils.showToast(mContext, "连接server失败,错误原因:" + e.getMessage(), Toast.LENGTH_LONG);
}
e.printStackTrace();
}
}
private Emitter.Listener onConnect = args -> { private Emitter.Listener onConnect = args -> {
Utils.i(AppConfig.TAG_UPDATE, "update socket connected"); Utils.i(AppConfig.TAG_UPDATE, "update socket connected");
if (AppConfig.DEBUG) { if (AppConfig.DEBUG) {
...@@ -62,7 +75,8 @@ public class UpdateSocket extends Thread { ...@@ -62,7 +75,8 @@ public class UpdateSocket extends Thread {
}; };
private Emitter.Listener onDisconnect = args -> { private Emitter.Listener onDisconnect = args -> {
Utils.i(AppConfig.TAG_UPDATE, "update socket disconnected"); Utils.i(AppConfig.TAG_UPDATE, "update socket disconnected");;
reconnect();
if (AppConfig.DEBUG) { if (AppConfig.DEBUG) {
Utils.showToast(mContext, "update socket, 断开连接", Toast.LENGTH_LONG); Utils.showToast(mContext, "update socket, 断开连接", Toast.LENGTH_LONG);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment