Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
haikang-client
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
杨立
haikang-client
Commits
85b9dd81
提交
85b9dd81
authored
9月 24, 2021
作者:
wangqiang
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
# Conflicts: # apq-pc-client/src/main/java/com/priusis/client/service/core/MqttServiceImpl.java
上级
f719a1c3
8b03b3e8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
9 行删除
+21
-9
MqttServiceImpl.java
...java/com/priusis/client/service/core/MqttServiceImpl.java
+18
-5
RemoteControlController.java
.../java/com/priusis/controller/RemoteControlController.java
+3
-4
没有找到文件。
apq-pc-client/src/main/java/com/priusis/client/service/core/MqttServiceImpl.java
浏览文件 @
85b9dd81
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
(
IO
Exception
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
{
...
...
apq-pc-client/src/main/java/com/priusis/controller/RemoteControlController.java
浏览文件 @
85b9dd81
...
@@ -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
();
p
rivate
synchronized
R
<
Void
>
startVncServer
(
long
minutes
)
p
ublic
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论