]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
MainService: minor changes to reporting and client handling
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 19 Feb 2019 01:00:02 +0000 (01:00 +0000)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 19 Feb 2019 01:19:14 +0000 (01:19 +0000)
Don't set the state on timesync events.
Null out the client handle slightly earlier.

mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java

index 6a28839accac85a60251b28f2a428ed00a4b545f..35f3437b50dd5764a937ee16e4b5a548a55c6861 100644 (file)
@@ -137,7 +137,7 @@ public class MainService extends Service {
                             return;
                         }
                         lastServerTimeDeltaEstimate = rxtime - mtime;
-                        setMSE(MqttServerEvent.MSE_SUB);
+                        notifyMSE();
                     }
                 });
 
@@ -238,7 +238,7 @@ public class MainService extends Service {
                 Log.d("Service", "domqtt disconn close mqtt", me);
             }
             mMqc.unregisterResources();
-
+            mMqc = null;
         } else {
             Log.d("Service", "domqtt no client");
         }
@@ -267,7 +267,6 @@ public class MainService extends Service {
 
         // If disconnecting is all we were told to do, we're done.
         if (server == null) {
-            mMqc = null;
             return;
         }
 
@@ -325,10 +324,15 @@ public class MainService extends Service {
         void onHandbookFetch(LocalBinder b);
     }
     private final Set<Observer> mObsvs = new HashSet<>();
+    private void notifyMSE() {
+        synchronized(this) {
+            for (Observer o : mObsvs) { o.onMqttServerEvent(mBinder, mMSE); }
+        }
+    }
     private void setMSE(MqttServerEvent mse) {
         synchronized(this) {
             mMSE = mse;
-            for (Observer o : mObsvs) { o.onMqttServerEvent(mBinder, mse); }
+            notifyMSE();
         }
     }
     private void notifyServerChanged(String sURL) {