Skip to content

Commit

Permalink
prevent crash when connect realtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ariefnurputranto committed Jun 16, 2020
1 parent 8a11f6f commit 5a42183
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,19 @@ private void buildClient() {
String epochTime = epochTimeLong.toString();

mqttAndroidClient = null;
mqttAndroidClient = new MqttAndroidClient(QiscusCore.getApps().getApplicationContext(),
QiscusCore.getMqttBrokerUrl(), clientId + epochTime, new MemoryPersistence());
mqttAndroidClient.setCallback(this);
mqttAndroidClient.setTraceEnabled(false);

try {
mqttAndroidClient = new MqttAndroidClient(QiscusCore.getApps().getApplicationContext(),
QiscusCore.getMqttBrokerUrl(), clientId + epochTime, new MemoryPersistence());
mqttAndroidClient.setCallback(this);
mqttAndroidClient.setTraceEnabled(false);
} catch (NullPointerException n) {
mqttAndroidClient = new MqttAndroidClient(QiscusCore.getApps().getApplicationContext(),
QiscusCore.getMqttBrokerUrl(), clientId + epochTime);
mqttAndroidClient.setCallback(this);
mqttAndroidClient.setTraceEnabled(false);
}

}

/**
Expand Down

0 comments on commit 5a42183

Please sign in to comment.