Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
[WIP] add mqtt client count on model
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <[email protected]>
  • Loading branch information
rafaelje committed Oct 30, 2018
1 parent 12b2cd9 commit ca3cf20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ public class MqttModel implements mqtt.Model {
private long timeLastReconnection = 0;
private Boolean executeConnection = true;
private int tryEverySeconds = 30;




private static int mqtt_object_count = 0;

public MqttModel(mqtt.Presenter presenter) {
mqttModelInstanceCount++;
Expand Down Expand Up @@ -185,6 +182,8 @@ public void connect(final Context context, final MqttCallback callback) {
MqttConnectOptions options;

if(client==null) {
mqtt_object_count++;
FlyveLog.d("MQTT Connect Call Count (connect): " + mqtt_object_count);
try {
clientId = MqttClient.generateClientId();
client = new MqttAndroidClient(context, protocol + "://" + mBroker + ":" + mPort, clientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
*/
public class MQTTService extends Service implements MqttCallback, mqtt.View {


private static int instanceCount = 0;
private static int connectCount = 0;

private mqtt.Presenter presenter;
IBinder mBinder = new LocalBinder();

Expand All @@ -62,9 +62,11 @@ public static Intent start(Context context) {
* Constructor
*/
public MQTTService() {
FlyveLog.d("MQTT Service Constructor");

instanceCount++;
FlyveLog.d("MQTT Service Constructor " + instanceCount);

presenter = new MqttPresenter(this);
}

Expand Down Expand Up @@ -103,6 +105,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {

connectCount++;
FlyveLog.d("MQTT Service Connect Call Count (onStartCommand): " + connectCount + "(instance count: " + instanceCount + ")");

presenter.connect(getApplicationContext(), MQTTService.this);
return START_STICKY;
}
Expand Down

0 comments on commit ca3cf20

Please sign in to comment.