提交 e658abe7 authored 作者: yangli's avatar yangli

.

上级 32df405f
...@@ -343,6 +343,10 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -343,6 +343,10 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
if ("remote_control".equals(mqttRpcDataMessage.getMethod())) {// 远程控制请求 if ("remote_control".equals(mqttRpcDataMessage.getMethod())) {// 远程控制请求
log.info("收到远程控制请求!!!"); log.info("收到远程控制请求!!!");
if (vncServerIsRunning()) {
log.warn("VNC Server 已在运行中,忽略此次请求");
return;
}
SysConfigUtil.saveProperty("control.request", "1"); SysConfigUtil.saveProperty("control.request", "1");
return; return;
} }
...@@ -359,6 +363,19 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -359,6 +363,19 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
} }
} }
private static boolean vncServerIsRunning() throws IOException {
Process process = Runtime.getRuntime().exec("cmd /c sc query uvnc_service");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) {
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.startsWith("STATE")) return line.endsWith("RUNNING");
}
process.destroy();
}
return false;
}
private void onGatewayAttributesGet(String message) { private void onGatewayAttributesGet(String message) {
log.info("Configuration arrived! {}", message); log.info("Configuration arrived! {}", message);
JsonNode payload = fromString(message); JsonNode payload = fromString(message);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论