提交 1e278d1c authored 作者: yangli's avatar yangli

.

上级 f156d50b
...@@ -351,8 +351,8 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -351,8 +351,8 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
return; return;
} }
if ("remote_control_exit".equals(mqttRpcDataMessage.getMethod())) { if ("remote_control_exit".equals(mqttRpcDataMessage.getMethod())) {
remoteControlController.timer.cancel(); log.info("推出远程控制!!!");
Runtime.getRuntime().exec("cmd /c net stop uvnc_service"); remoteControlController.stopVncServer();
return; return;
} }
if ("remote_control_accept".equals(mqttRpcDataMessage.getMethod())) { if ("remote_control_accept".equals(mqttRpcDataMessage.getMethod())) {
......
...@@ -83,7 +83,7 @@ public class RemoteControlController { ...@@ -83,7 +83,7 @@ public class RemoteControlController {
return startVncServer(minutes); return startVncServer(minutes);
} }
public Timer timer = new Timer(); private Timer timer = new Timer();
public synchronized R<Void> startVncServer(long minutes) public synchronized R<Void> startVncServer(long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException { throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
...@@ -106,8 +106,7 @@ public class RemoteControlController { ...@@ -106,8 +106,7 @@ public class RemoteControlController {
configParser.write(file); configParser.write(file);
// 重启VNC Server服务 // 重启VNC Server服务
timer.cancel(); stopVncServer();
Runtime.getRuntime().exec("cmd /c net stop uvnc_service").waitFor();
Runtime.getRuntime().exec("cmd /c net start uvnc_service").waitFor(); Runtime.getRuntime().exec("cmd /c net start uvnc_service").waitFor();
// 定时任务,指定分钟后执行一次 // 定时任务,指定分钟后执行一次
...@@ -116,14 +115,17 @@ public class RemoteControlController { ...@@ -116,14 +115,17 @@ public class RemoteControlController {
@SneakyThrows @SneakyThrows
@Override @Override
public void run() { public void run() {
// 停止VNC Server服务 stopVncServer();
Runtime.getRuntime().exec("cmd /c net stop uvnc_service");
timer.cancel();
} }
}, minutes * 60 * 1000); }, minutes * 60 * 1000);
return R.success(); return R.success();
} }
public void stopVncServer() throws IOException, InterruptedException {
Runtime.getRuntime().exec("cmd /c net stop uvnc_service").waitFor();
if (timer != null) timer.cancel();
}
/** /**
* 拒绝远程控制请求 * 拒绝远程控制请求
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论