ChildDeviceMessage
This commit is contained in:
parent
ecf4e534b3
commit
f0f474f3ae
|
@ -10,6 +10,7 @@ import org.jetlinks.core.message.firmware.*;
|
||||||
import org.jetlinks.core.message.function.FunctionInvokeMessage;
|
import org.jetlinks.core.message.function.FunctionInvokeMessage;
|
||||||
import org.jetlinks.core.message.function.FunctionInvokeMessageReply;
|
import org.jetlinks.core.message.function.FunctionInvokeMessageReply;
|
||||||
import org.jetlinks.core.message.property.*;
|
import org.jetlinks.core.message.property.*;
|
||||||
|
import org.jetlinks.core.utils.TopicUtils;
|
||||||
import org.jetlinks.supports.utils.MqttTopicUtils;
|
import org.jetlinks.supports.utils.MqttTopicUtils;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
@ -41,14 +42,14 @@ class JetlinksTopicMessageCodec {
|
||||||
|
|
||||||
public DecodeResult(String topic) {
|
public DecodeResult(String topic) {
|
||||||
this.topic = topic;
|
this.topic = topic;
|
||||||
args = MqttTopicUtils.getPathVariables("/{productId}/{deviceId}/**", topic);
|
args = TopicUtils.getPathVariables("/{productId}/{deviceId}/**", topic);
|
||||||
if (topic.contains("child")) {
|
if (topic.contains("child")) {
|
||||||
child = true;
|
child = true;
|
||||||
args.putAll(MqttTopicUtils.getPathVariables("/**/child/{childDeviceId}/**", topic));
|
args.putAll(TopicUtils.getPathVariables("/**/child/{childDeviceId}/**", topic));
|
||||||
}
|
}
|
||||||
if (topic.contains("event")) {
|
if (topic.contains("event")) {
|
||||||
event = true;
|
event = true;
|
||||||
args.putAll(MqttTopicUtils.getPathVariables("/**/event/{eventId}", topic));
|
args.putAll(TopicUtils.getPathVariables("/**/event/{eventId}", topic));
|
||||||
}
|
}
|
||||||
derivedMetadata = topic.endsWith("metadata/derived");
|
derivedMetadata = topic.endsWith("metadata/derived");
|
||||||
if (event) {
|
if (event) {
|
||||||
|
@ -190,11 +191,10 @@ class JetlinksTopicMessageCodec {
|
||||||
throw new UnsupportedOperationException("unsupported topic:" + topic);
|
throw new UnsupportedOperationException("unsupported topic:" + topic);
|
||||||
}
|
}
|
||||||
applyCommons(message, result, object);
|
applyCommons(message, result, object);
|
||||||
ChildDeviceMessageReply children = new ChildDeviceMessageReply();
|
ChildDeviceMessage children = new ChildDeviceMessage();
|
||||||
children.setChildDeviceId(result.getChildDeviceId());
|
children.setChildDeviceId(result.getChildDeviceId());
|
||||||
children.setDeviceId(result.getDeviceId());
|
children.setDeviceId(result.getDeviceId());
|
||||||
children.setChildDeviceMessage(message);
|
children.setChildDeviceMessage(message);
|
||||||
children.setSuccess(Optional.ofNullable(object.getBoolean("success")).orElse(true));
|
|
||||||
children.setTimestamp(Optional.ofNullable(object.getLong("timestamp")).orElse(System.currentTimeMillis()));
|
children.setTimestamp(Optional.ofNullable(object.getLong("timestamp")).orElse(System.currentTimeMillis()));
|
||||||
Optional.ofNullable(object.getString("messageId")).ifPresent(children::setMessageId);
|
Optional.ofNullable(object.getString("messageId")).ifPresent(children::setMessageId);
|
||||||
result.message = children;
|
result.message = children;
|
||||||
|
|
Loading…
Reference in New Issue