-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
66 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...aging/src/main/java/com/tuya/connector/open/messaging/autoconfig/MessageScanRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.tuya.connector.open.messaging.autoconfig; | ||
|
||
import com.tuya.connector.open.messaging.MessageRegister; | ||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; | ||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; | ||
import org.springframework.core.annotation.AnnotationAttributes; | ||
import org.springframework.core.type.AnnotationMetadata; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class MessageScanRegister implements ImportBeanDefinitionRegistrar { | ||
@Override | ||
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) { | ||
AnnotationAttributes attributes = AnnotationAttributes.fromMap(annotationMetadata.getAnnotationAttributes(EnableMessaging.class.getName())); | ||
Set<String> pkgPaths = new HashSet<>(); | ||
if (attributes != null) { | ||
String[] paths = attributes.getStringArray("msgPaths"); | ||
pkgPaths.addAll(Arrays.asList(paths)); | ||
} | ||
MessageRegister.init(pkgPaths); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...rc/main/java/com/tuya/open/spring/boot/sample/ability/messaging/msg/DeviceNameUpdate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.tuya.open.spring.boot.sample.ability.messaging.msg; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.tuya.connector.open.messaging.SourceMessage; | ||
import com.tuya.connector.open.messaging.event.BaseTuyaMessage; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class DeviceNameUpdate extends BaseTuyaMessage { | ||
|
||
private String devId; | ||
private String produceId; | ||
private String uid; | ||
private String name; | ||
private String uuid; | ||
|
||
@Override | ||
public void defaultBuild(SourceMessage sourceMessage, JSONObject messageBody) { | ||
super.defaultBuild(sourceMessage, messageBody); | ||
this.devId = messageBody.getString("devId"); | ||
this.produceId = messageBody.getString("produceId"); | ||
this.uid = messageBody.getString("uid"); | ||
this.name = messageBody.getString("name"); | ||
this.uuid = messageBody.getString("uuid"); | ||
} | ||
|
||
@Override | ||
public String type() { | ||
return "deviceNameUpdate"; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
tuya-spring-boot-starter-sample/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
connector.ak=stehdkw4navw5mwagh4d | ||
connector.sk=fdc94f366dad4acc926a730551080665 | ||
connector.ak= | ||
connector.sk= |