/** * Request all clients to reconnect if appropriate */ void reconnect() { traceDebug(TAG, "Reconnect to server, client size=" + connections.size()); for (MqttConnection client : connections.values()) { traceDebug("Reconnect Client:", client.getClientId() + '/' + client.getServerURI()); if(this.isOnline()){ client.reconnect(); } } }
@Override @SuppressLint("Wakelock") public void onReceive(Context context, Intent intent) { traceDebug(TAG, "Internal network status receive."); // we protect against the phone switching off // by requesting a wake lock - we request the minimum possible wake // lock - just enough to keep the CPU running until we've finished PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); WakeLock wl = pm .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT"); wl.acquire(); traceDebug(TAG,"Reconnect for Network recovery."); if (isOnline()) { traceDebug(TAG,"Online,reconnect."); // we have an internet connection - have another try at // connecting reconnect(); } else { notifyClientsOffline(); } wl.release(); } }
if(!service.isOnline()){ service.traceDebug(TAG, "The network is not reachable. Will not do reconnect");
/** * Request all clients to reconnect if appropriate */ void reconnect() { traceDebug(TAG, "Reconnect to server, client size=" + connections.size()); for (MqttConnection client : connections.values()) { traceDebug("Reconnect Client:", client.getClientId() + '/' + client.getServerURI()); if(this.isOnline()){ client.reconnect(); } } }
/** * Request all clients to reconnect if appropriate */ void reconnect() { traceDebug(TAG, "Reconnect to server, client size=" + connections.size()); for (MqttConnection client : connections.values()) { traceDebug("Reconnect Client:", client.getClientId() + '/' + client.getServerURI()); if(this.isOnline()){ client.reconnect(); } } }
@Override @SuppressLint("Wakelock") public void onReceive(Context context, Intent intent) { traceDebug(TAG, "Internal network status receive."); // we protect against the phone switching off // by requesting a wake lock - we request the minimum possible wake // lock - just enough to keep the CPU running until we've finished PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); WakeLock wl = pm .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT"); wl.acquire(); traceDebug(TAG,"Reconnect for Network recovery."); if (isOnline()) { traceDebug(TAG,"Online,reconnect."); // we have an internet connection - have another try at // connecting reconnect(); } else { notifyClientsOffline(); } wl.release(); } }
@Override @SuppressLint("Wakelock") public void onReceive(Context context, Intent intent) { traceDebug(TAG, "Internal network status receive."); // we protect against the phone switching off // by requesting a wake lock - we request the minimum possible wake // lock - just enough to keep the CPU running until we've finished PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); WakeLock wl = pm .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT"); wl.acquire(); traceDebug(TAG,"Reconnect for Network recovery."); if (isOnline()) { traceDebug(TAG,"Online,reconnect."); // we have an internet connection - have another try at // connecting reconnect(); } else { notifyClientsOffline(); } wl.release(); } }
if(!service.isOnline()){ service.traceDebug(TAG, "The network is not reachable. Will not do reconnect");
if(!service.isOnline()){ service.traceDebug(TAG, "The network is not reachable. Will not do reconnect");