Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mica
mica-mqtt
提交
6892a2e4
mica-mqtt
项目概览
mica
/
mica-mqtt
通知
71
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
mica-mqtt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6892a2e4
编写于
3月 15, 2021
作者:
如梦技术
🐛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
代码优化。
上级
2837b697
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
56 addition
and
50 deletion
+56
-50
mica-mqtt-codec/pom.xml
mica-mqtt-codec/pom.xml
+1
-1
mica-mqtt-codec/src/main/java/net/dreamlu/iot/mqtt/codec/MqttMessageBuilders.java
.../java/net/dreamlu/iot/mqtt/codec/MqttMessageBuilders.java
+6
-9
mica-mqtt-core/pom.xml
mica-mqtt-core/pom.xml
+1
-1
mica-mqtt-core/src/main/java/net/dreamlu/iot/mqtt/core/client/MqttClient.java
...ain/java/net/dreamlu/iot/mqtt/core/client/MqttClient.java
+14
-6
mica-mqtt-example/pom.xml
mica-mqtt-example/pom.xml
+1
-1
mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/aliyun/MqttClientTest.java
...main/java/net/dreamlu/iot/mqtt/aliyun/MqttClientTest.java
+3
-2
pom.xml
pom.xml
+30
-30
未找到文件。
mica-mqtt-codec/pom.xml
浏览文件 @
6892a2e4
...
...
@@ -6,7 +6,7 @@
<parent>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-mqtt
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
2021.00
</version>
</parent>
<artifactId>
mica-mqtt-codec
</artifactId>
...
...
mica-mqtt-codec/src/main/java/net/dreamlu/iot/mqtt/codec/MqttMessageBuilders.java
浏览文件 @
6892a2e4
...
...
@@ -506,8 +506,7 @@ public final class MqttMessageBuilders {
}
public
static
final
class
PubAckBuilder
{
private
short
packetId
;
private
int
packetId
;
private
byte
reasonCode
;
private
MqttProperties
properties
;
...
...
@@ -519,7 +518,7 @@ public final class MqttMessageBuilders {
return
this
;
}
public
PubAckBuilder
packetId
(
shor
t
packetId
)
{
public
PubAckBuilder
packetId
(
in
t
packetId
)
{
this
.
packetId
=
packetId
;
return
this
;
}
...
...
@@ -539,15 +538,14 @@ public final class MqttMessageBuilders {
}
public
static
final
class
SubAckBuilder
{
private
short
packetId
;
private
int
packetId
;
private
MqttProperties
properties
;
private
final
List
<
MqttQoS
>
grantedQosList
=
new
ArrayList
<>();
SubAckBuilder
()
{
}
public
SubAckBuilder
packetId
(
shor
t
packetId
)
{
public
SubAckBuilder
packetId
(
in
t
packetId
)
{
this
.
packetId
=
packetId
;
return
this
;
}
...
...
@@ -586,15 +584,14 @@ public final class MqttMessageBuilders {
}
public
static
final
class
UnsubAckBuilder
{
private
short
packetId
;
private
int
packetId
;
private
MqttProperties
properties
;
private
final
List
<
Short
>
reasonCodes
=
new
ArrayList
<>();
UnsubAckBuilder
()
{
}
public
UnsubAckBuilder
packetId
(
shor
t
packetId
)
{
public
UnsubAckBuilder
packetId
(
in
t
packetId
)
{
this
.
packetId
=
packetId
;
return
this
;
}
...
...
mica-mqtt-core/pom.xml
浏览文件 @
6892a2e4
...
...
@@ -6,7 +6,7 @@
<parent>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-mqtt
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
2021.00
</version>
</parent>
<artifactId>
mica-mqtt-core
</artifactId>
...
...
mica-mqtt-core/src/main/java/net/dreamlu/iot/mqtt/core/client/MqttClient.java
浏览文件 @
6892a2e4
...
...
@@ -62,9 +62,7 @@ public final class MqttClient {
.
addSubscription
(
MqttQoS
.
AT_MOST_ONCE
,
topicFilter
)
.
messageId
(
MqttClientMessageId
.
getId
())
.
build
();
Tio
.
send
(
context
,
message
);
// 绑定 subManage listener
return
this
;
return
subscribe
(
message
,
listener
);
}
/**
...
...
@@ -80,9 +78,7 @@ public final class MqttClient {
.
addSubscription
(
MqttQoS
.
AT_LEAST_ONCE
,
topicFilter
)
.
messageId
(
MqttClientMessageId
.
getId
())
.
build
();
Tio
.
send
(
context
,
message
);
// 绑定 subManage listener
return
this
;
return
subscribe
(
message
,
listener
);
}
/**
...
...
@@ -99,6 +95,18 @@ public final class MqttClient {
.
messageId
(
MqttClientMessageId
.
getId
())
.
build
();
Tio
.
send
(
context
,
message
);
return
subscribe
(
message
,
listener
);
}
/**
* 订阅
*
* @param message MqttSubscribeMessage
* @param listener MqttMessageListener
* @return MqttClient
*/
public
MqttClient
subscribe
(
MqttSubscribeMessage
message
,
MqttMessageListener
listener
)
{
Tio
.
send
(
context
,
message
);
// 绑定 subManage listener
return
this
;
}
...
...
mica-mqtt-example/pom.xml
浏览文件 @
6892a2e4
...
...
@@ -6,7 +6,7 @@
<parent>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-mqtt
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
2021.00
</version>
</parent>
<artifactId>
mica-mqtt-example
</artifactId>
...
...
mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/aliyun/MqttClientTest.java
浏览文件 @
6892a2e4
...
...
@@ -34,11 +34,12 @@ public class MqttClientTest {
.
clientId
(
clientId
)
.
connect
();
client
.
subQos0
(
"/sys/
g27jB42P9hm/3dbc1cb4
/thing/event/property/post_reply"
,
(
topic
,
payload
)
->
{
client
.
subQos0
(
"/sys/
"
+
productKey
+
"/"
+
deviceName
+
"
/thing/event/property/post_reply"
,
(
topic
,
payload
)
->
{
});
String
content
=
"{\"id\":\"1\",\"version\":\"1.0\",\"params\":{\"LightSwitch\":1}}"
;
client
.
publish
(
"/sys/
g27jB42P9hm
/"
+
deviceName
+
"/thing/event/property/post"
,
ByteBuffer
.
wrap
(
content
.
getBytes
()));
client
.
publish
(
"/sys/
"
+
productKey
+
"
/"
+
deviceName
+
"/thing/event/property/post"
,
ByteBuffer
.
wrap
(
content
.
getBytes
()));
}
}
pom.xml
浏览文件 @
6892a2e4
...
...
@@ -4,37 +4,17 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-mqtt
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
2021.00
</version>
<packaging>
pom
</packaging>
<name>
${project.artifactId}
</name>
<description>
Mica mqtt tools.
</description>
<url>
https://www.dreamlu.net/
</url>
<licenses>
<license>
<name>
Apache License 2.0
</name>
<url>
http://www.apache.org/licenses
</url>
</license>
</licenses>
<developers>
<developer>
<name>
ChunmengLu
</name>
<email>
qq596392912@gmail.com
</email>
</developer>
</developers>
<scm>
<connection>
scm:git:git@git.oschina.net/596392912/mica-mqtt
</connection>
<developerConnection>
scm:git:git@git.oschina.net/596392912/mica-mqtt.git
</developerConnection>
<url>
git@git.oschina.net/596392912/mica-mqtt.git
</url>
</scm>
<properties>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<mica-iot.version>
0.0.1-SNAPSHOT
</mica-iot.version>
<mica-iot.version>
2021.00
</mica-iot.version>
<tio.version>
3.7.1.v20210106-RELEASE
</tio.version>
<slf4j.version>
1.7.25
</slf4j.version>
</properties>
...
...
@@ -65,6 +45,28 @@
</dependencies>
</dependencyManagement>
<developers>
<developer>
<name>
ChunmengLu
</name>
<email>
qq596392912@gmail.com
</email>
</developer>
</developers>
<scm>
<connection>
scm:git:git@git.oschina.net/596392912/mica-mqtt
</connection>
<developerConnection>
scm:git:git@git.oschina.net/596392912/mica-mqtt.git
</developerConnection>
<url>
git@git.oschina.net/596392912/mica-mqtt.git
</url>
</scm>
<repositories>
<!--阿里云主仓库,代理了 maven central 和 jcenter 仓库-->
<repository>
<id>
aliyun
</id>
<name>
aliyun
</name>
<url>
https://maven.aliyun.com/repository/public
</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
...
...
@@ -80,14 +82,12 @@
</plugins>
</build>
<repositories>
<!--阿里云主仓库,代理了 maven central 和 jcenter 仓库-->
<repository>
<id>
aliyun
</id>
<name>
aliyun
</name>
<url>
https://maven.aliyun.com/repository/public
</url>
</repository>
</repositories>
<licenses>
<license>
<name>
Apache License 2.0
</name>
<url>
http://www.apache.org/licenses
</url>
</license>
</licenses>
<profiles>
<profile>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录