LOG.info("Before waiting to receive 1 sec from {}", clientForSubscribe1.getClientId()); assertFalse(clientForSubscribe1.isConnected()); assertTrue(clientForSubscribe2.isConnected()); LOG.info("Waiting to receive 1 sec from {}", clientForSubscribe2.getClientId()); MqttMessage messageOnB = cbSubscriber2.waitMessage(1); assertEquals("Hello", new String(messageOnB.getPayload(), UTF_8));
/** * Gets the clientId of the wrapped {@link MqttClient#pahoMqttClient}. * * @return The clientId of the wrapped {@link MqttClient#pahoMqttClient}. */ public String getClientId() { try { return getPahoClient().getClientId(); } catch (KapuaException e) { return null; } }
/** * Gets the clientId of the wrapped {@link MqttClient#pahoMqttClient}. * * @return The clientId of the wrapped {@link MqttClient#pahoMqttClient}. */ public String getClientId() { try { return getPahoClient().getClientId(); } catch (KapuaException e) { return null; } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); if (PERMISSIONS_OK) { DEBUG = Aware.getSetting(this, Aware_Preferences.DEBUG_FLAG).equals("true"); if (Aware.is_watch(this)) { Log.d(TAG, "This is an Android Wear device, we can't connect to MQTT. Disabling it!"); Aware.setSetting(this, Aware_Preferences.STATUS_MQTT, false); stopSelf(); } else { Aware.setSetting(this, Aware_Preferences.STATUS_MQTT, true); if (MQTT_CLIENT != null && MQTT_CLIENT.isConnected()) { if (DEBUG) Log.d(TAG, "MQTT: Client ID=" + MQTT_CLIENT.getClientId() + "\n Server:" + MQTT_CLIENT.getServerURI()); } else { initializeMQTT(); } } } return START_STICKY; }
Log.d(TAG, "MQTT: Client ID=" + MQTT_CLIENT.getClientId() + "\n Server:" + MQTT_CLIENT.getServerURI());