exe读取扫码结果

This commit is contained in:
砂糖
2025-08-23 13:56:54 +08:00
parent 026216a9b1
commit b0629cc13b
4 changed files with 509 additions and 253 deletions

View File

@@ -18,13 +18,13 @@ public class WsServer {
sessions.add(session);
System.out.println("WebSocket连接已建立: " + session.getId());
// 推送所有扫码枪列表给前端(使用修改后的方法名)
String deviceListJson = Main.getAllDevicesJson();
try {
System.out.println("发送设备列表到前端: " + deviceListJson);
session.getBasicRemote().sendText(deviceListJson);
} catch (IOException e) {
e.printStackTrace();
}
// String deviceListJson = Main.getAllDevicesJson();
// try {
// System.out.println("发送设备列表到前端: " + deviceListJson);
// session.getBasicRemote().sendText(deviceListJson);
// } catch (IOException e) {
// e.printStackTrace();
// }
}
@OnMessage
@@ -32,8 +32,8 @@ public class WsServer {
System.out.println("收到消息: " + message);
// 可以根据前端需求,在这里处理命令(比如刷新设备列表)
if ("refreshDevices".equals(message)) {
String deviceListJson = Main.getAllDevicesJson();
session.getBasicRemote().sendText(deviceListJson);
// String deviceListJson = Main.getAllDevicesJson();
// session.getBasicRemote().sendText(deviceListJson);
} else {
session.getBasicRemote().sendText("服务器已收到: " + message);
}