Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-mqtt-protocol
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
551b0435
authored
Apr 02, 2024
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: 心跳
parent
f163c0d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
src/main/java/org/jetlinks/protocol/official/TopicMessageCodec.java
src/main/java/org/jetlinks/protocol/official/TopicMessageCodec.java
View file @
551b0435
package
org
.
jetlinks
.
protocol
.
official
;
package
org
.
jetlinks
.
protocol
.
official
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.SneakyThrows
;
import
lombok.SneakyThrows
;
import
org.hswebframework.web.bean.FastBeanCopier
;
import
org.hswebframework.web.bean.FastBeanCopier
;
...
@@ -21,10 +22,8 @@ import org.reactivestreams.Publisher;
...
@@ -21,10 +22,8 @@ import org.reactivestreams.Publisher;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
java.util.Arrays
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Collections
;
import
java.util.*
;
import
java.util.Optional
;
import
java.util.StringJoiner
;
import
java.util.function.Function
;
import
java.util.function.Function
;
public
enum
TopicMessageCodec
{
public
enum
TopicMessageCodec
{
...
@@ -282,6 +281,22 @@ public enum TopicMessageCodec {
...
@@ -282,6 +281,22 @@ public enum TopicMessageCodec {
//状态检查
//状态检查
stateCheck
(
"/*/state-check"
,
DeviceStateCheckMessage
.
class
),
stateCheck
(
"/*/state-check"
,
DeviceStateCheckMessage
.
class
),
stateCheckReply
(
"/*/state-check/reply"
,
DeviceStateCheckMessageReply
.
class
),
stateCheckReply
(
"/*/state-check/reply"
,
DeviceStateCheckMessageReply
.
class
),
//心跳
heartbeat
(
"/*/heartbeat"
,
DeviceLogMessage
.
class
)
{
@Override
Publisher
<
DeviceMessage
>
doDecode
(
ObjectMapper
mapper
,
String
[]
topic
,
byte
[]
payload
)
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
new
String
(
payload
,
StandardCharsets
.
UTF_8
));
JSONObject
properties
=
jsonObject
.
getJSONObject
(
"payload"
);
DeviceLogMessage
msg
=
new
DeviceLogMessage
();
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"deviceId"
,
topic
[
1
]);
content
.
put
(
"messageType"
,
"HEARTBEAT"
);
content
.
put
(
"properties"
,
properties
.
getInnerMap
());
content
.
put
(
"timestamp"
,
msg
.
getTimestamp
());
msg
.
setLog
(
JSONObject
.
toJSONString
(
content
));
return
Mono
.
just
(
msg
);
}
},
;
;
TopicMessageCodec
(
String
topic
,
TopicMessageCodec
(
String
topic
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment