提交 85b9dd81 authored 作者: wangqiang's avatar wangqiang

Merge remote-tracking branch 'origin/master'

# Conflicts: # apq-pc-client/src/main/java/com/priusis/client/service/core/MqttServiceImpl.java
package com.priusis.client.service.core; package com.priusis.client.service.core;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -11,6 +12,7 @@ import com.priusis.client.service.*; ...@@ -11,6 +12,7 @@ import com.priusis.client.service.*;
import com.priusis.client.service.conf.*; import com.priusis.client.service.conf.*;
import com.priusis.client.service.data.*; import com.priusis.client.service.data.*;
import com.priusis.client.util.JsonTools; import com.priusis.client.util.JsonTools;
import com.priusis.controller.RemoteControlController;
import com.priusis.monitor.mqtt.*; import com.priusis.monitor.mqtt.*;
import com.priusis.util.SysConfigUtil; import com.priusis.util.SysConfigUtil;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
...@@ -26,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -26,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
import oshi.hardware.NetworkIF; import oshi.hardware.NetworkIF;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import java.io.*; import java.io.*;
...@@ -349,6 +352,10 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -349,6 +352,10 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
} }
} }
@Resource
private RemoteControlController remoteControlController;
private void onRpcCommand(String message) { private void onRpcCommand(String message) {
JsonNode payload = fromString(message); JsonNode payload = fromString(message);
MqttRpcDataMessage mqttRpcDataMessage = MqttRpcDataMessage.builder().requestId(payload.get("id").asInt()) MqttRpcDataMessage mqttRpcDataMessage = MqttRpcDataMessage.builder().requestId(payload.get("id").asInt())
...@@ -359,12 +366,18 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -359,12 +366,18 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
try { try {
if ("remote_control".equals(mqttRpcDataMessage.getMethod())) {// 远程控制请求 if ("remote_control".equals(mqttRpcDataMessage.getMethod())) {// 远程控制请求
log.debug("收到远程控制请求!!!");
SysConfigUtil.saveProperty("control.request", "1"); SysConfigUtil.saveProperty("control.request", "1");
return; return;
} }
if ("remote_control_accept".equals(mqttRpcDataMessage.getMethod())) {
Long minutes = Convert.toLong(mqttRpcDataMessage.getParams());
remoteControlController.startVncServer(minutes);
return;
}
persistentFileService.flushRpcDataToFile(mqttRpcDataMessage); persistentFileService.flushRpcDataToFile(mqttRpcDataMessage);
} catch (IOException e) { } catch (Exception e) {
log.error("Failed to process rpc command persistent : {}", message); log.error("Failed to process rpc command persistent : {}", message);
} }
} }
...@@ -678,10 +691,10 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -678,10 +691,10 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
} catch (Exception e) { } catch (Exception e) {
log.error("获取Mac地址注册设备信息异常", e); log.error("获取Mac地址注册设备信息异常", e);
} }
MqttClientSecurityConfiguration mqttClientSecurityConfiguration = new MqttClientSecurityConfiguration(); //MqttClientSecurityConfiguration mqttClientSecurityConfiguration = new MqttClientSecurityConfiguration();
mqttClientSecurityConfiguration.setAccessToken("D6qjl0xNnDMtgSPMczGt"); //mqttClientSecurityConfiguration.setAccessToken("D6qjl0xNnDMtgSPMczGt");
return mqttClientSecurityConfiguration; //return mqttClientSecurityConfiguration;
//return null; return null;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
......
...@@ -58,7 +58,7 @@ public class RemoteControlController { ...@@ -58,7 +58,7 @@ public class RemoteControlController {
private InstalledProgramCache installedProgramCache; private InstalledProgramCache installedProgramCache;
/** /**
* 前端定时任务查询远程控制请求,不为空则表示有请求,展示确认弹窗 * 前端定时任务查询远程控制请求,true则表示有请求,展示确认弹窗
*/ */
@GetMapping(value = "get_control_request") @GetMapping(value = "get_control_request")
public R<Boolean> getControlRequest() throws IOException { public R<Boolean> getControlRequest() throws IOException {
...@@ -78,7 +78,7 @@ public class RemoteControlController { ...@@ -78,7 +78,7 @@ public class RemoteControlController {
private Timer timer = new Timer(); private Timer timer = new Timer();
private 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 {
// 查询设备的远程ID // 查询设备的远程ID
String remoteId = getRemoteId(); String remoteId = getRemoteId();
...@@ -129,11 +129,10 @@ public class RemoteControlController { ...@@ -129,11 +129,10 @@ 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, InterruptedException { throws IOException {
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"));
startVncServer(minutes);
return R.success(); return R.success();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论