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

.

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