提交 7f56adfe authored 作者: yangli's avatar yangli

.

上级 1f3ef355
...@@ -70,7 +70,7 @@ public class RemoteControlController { ...@@ -70,7 +70,7 @@ public class RemoteControlController {
*/ */
@GetMapping(value = "accept_request") @GetMapping(value = "accept_request")
public R<Void> acceptRequest(@RequestParam @NotNull Long minutes) public R<Void> acceptRequest(@RequestParam @NotNull Long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException { throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
Boolean hasRequest = Convert.toBool(SysConfigUtil.saveProperty("control.request", "0"), false); Boolean hasRequest = Convert.toBool(SysConfigUtil.saveProperty("control.request", "0"), false);
if (!hasRequest) return R.error("无远程请求"); if (!hasRequest) return R.error("无远程请求");
return startVncServer(minutes); return startVncServer(minutes);
...@@ -79,7 +79,7 @@ public class RemoteControlController { ...@@ -79,7 +79,7 @@ public class RemoteControlController {
private Timer timer = new Timer(); private Timer timer = new Timer();
private synchronized R<Void> startVncServer(long minutes) private synchronized R<Void> startVncServer(long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException { throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
// 查询设备的远程ID // 查询设备的远程ID
String remoteId = getRemoteId(); String remoteId = getRemoteId();
if (StrUtil.isBlank(remoteId)) return R.error("未查询到设备的远程ID"); if (StrUtil.isBlank(remoteId)) return R.error("未查询到设备的远程ID");
...@@ -98,9 +98,10 @@ public class RemoteControlController { ...@@ -98,9 +98,10 @@ public class RemoteControlController {
StrUtil.format("-autoreconnect ID:{} -connect {} -run", remoteId, vncRepeater)); StrUtil.format("-autoreconnect ID:{} -connect {} -run", remoteId, vncRepeater));
configParser.write(file); configParser.write(file);
// 启动VNC Server服务 // 重启VNC Server服务
timer.cancel(); timer.cancel();
Runtime.getRuntime().exec("cmd /c net start uvnc_service"); Runtime.getRuntime().exec("cmd /c net stop uvnc_service").waitFor();
Runtime.getRuntime().exec("cmd /c net start uvnc_service").waitFor();
// 定时任务,指定分钟后执行一次 // 定时任务,指定分钟后执行一次
timer = new Timer(); timer = new Timer();
...@@ -128,7 +129,7 @@ public class RemoteControlController { ...@@ -128,7 +129,7 @@ public class RemoteControlController {
@GetMapping(value = "send_request") @GetMapping(value = "send_request")
public R<Void> sendRequest(@RequestParam @NotNull Long minutes) public R<Void> sendRequest(@RequestParam @NotNull Long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException { throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
JSONObject rsp = JSONUtil.parseObj(HttpUtil.post(gateway + sendControlReqUrl, JSONObject rsp = JSONUtil.parseObj(HttpUtil.post(gateway + sendControlReqUrl,
JSONUtil.createObj().set("minutes", minutes).set("macAddress", getMacAddress()).toString())); JSONUtil.createObj().set("minutes", minutes).set("macAddress", getMacAddress()).toString()));
if (ObjectUtil.notEqual(rsp.getInt("code"), 0)) return R.error(rsp.getStr("msg")); if (ObjectUtil.notEqual(rsp.getInt("code"), 0)) return R.error(rsp.getStr("msg"));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论