Skip to content

Commit

Permalink
mqtt publish 为空处理
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheedon committed Jul 28, 2020
1 parent 3de694c commit a5b3edc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mqtt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 4
versionName "1.1.2"
versionCode 5
versionName "1.1.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down
16 changes: 11 additions & 5 deletions mqtt/src/main/java/org/sheedon/mqtt/RealCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

/**
* 真实反馈类
* * 异步执行数据请求
* * 1. 获取是否需要反馈,有反馈监听才需要添加反馈
* * 2. 无需反馈,直接发送完成
* * 3. 需要反馈,添加任务队列Map<name,listener>
* * 异步执行数据请求
* * 1. 获取是否需要反馈,有反馈监听才需要添加反馈
* * 2. 无需反馈,直接发送完成
* * 3. 需要反馈,添加任务队列Map<name,listener>
*
* @Author: sheedon
* @Email: [email protected]
Expand All @@ -27,6 +27,7 @@ protected RealCall(RealClient client, Request originalRequest) {
this.client = client;
this.originalRequest = originalRequest;
}

/**
* 新增反馈类
*/
Expand Down Expand Up @@ -86,7 +87,7 @@ public Call clone() {
return null;
}

final class AsyncCall extends NamedRunnable implements AsyncCallImpl{
final class AsyncCall extends NamedRunnable implements AsyncCallImpl {

private final Callback responseCallback;
private final RealClient client;
Expand Down Expand Up @@ -153,6 +154,11 @@ protected void execute() {
String topic = request.topic();
if (topic == null || topic.isEmpty())
topic = mqttClient.baseTopic();

if (mqttClient == null || mqttClient.mqttClient() == null) {
client.dispatcher().finishedByLocal(id(), new Throwable("mqtt client is null"));
return;
}
mqttClient.mqttClient().publish(topic,
request.getBody());

Expand Down

0 comments on commit a5b3edc

Please sign in to comment.