Skip to content

Instantly share code, notes, and snippets.

@amanjeetsingh150
Last active September 23, 2018 14:03
Show Gist options
  • Save amanjeetsingh150/128b5b0a18c72903e16f81f43ba75f09 to your computer and use it in GitHub Desktop.
Save amanjeetsingh150/128b5b0a18c72903e16f81f43ba75f09 to your computer and use it in GitHub Desktop.
MQTTHelper mqttHelper = new MQTTHelper(getApplicationContext());
mqttHelper.setCallback(new MqttCallbackExtended() {
@Override
public void connectComplete(boolean reconnect, String serverURI) {
Log.d(TAG, "URI " + serverURI);
}
@Override
public void connectionLost(Throwable cause) {
cause.printStackTrace();
}
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
String payload = new String(message.getPayload());
LatLng currentLatLng = convertStringToLatLng(payload);
Log.d(TAG, topic + " " + currentLatLng);
latLngPublishRelay.accept(currentLatLng);
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
Log.d(TAG, "Delivery complete");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment