org.eclipse.paho.client.mqttv3.MqttCallbackExtended Java Examples

The following examples show how to use org.eclipse.paho.client.mqttv3.MqttCallbackExtended. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PushListActivity.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureMqttClient() {
    try {
        mqttClient = new MqttAsyncClient("tcp://test-io.Pushfish.api.push.fish:1883", "android", new MemoryPersistence());
        mqttClient.setCallback(new MqttCallbackExtended() {
            @Override
            public void connectComplete(boolean reconnect, String serverURI) {
                Log.i(PushListActivity.class.getName(), "MQTT Connection successful!");
            }

            @Override
            public void connectionLost(Throwable cause) {
                Log.w(PushListActivity.class.getName(), "MQTT Connection was lost!");
            }

            @Override
            public void messageArrived(String topic, MqttMessage message) {
                handleMessage(topic, message);
            }

            @Override
            public void deliveryComplete(IMqttDeliveryToken token) {

            }
        });
    } catch (MqttException e) {
        e.printStackTrace();
    }
}
 
Example #2
Source File: MqttAndroidClient.java    From Sparkplug with Eclipse Public License 1.0 5 votes vote down vote up
private void connectExtendedAction(Bundle data){
	// This is called differently from a normal connect

	if(callback instanceof MqttCallbackExtended){
		boolean reconnect = data.getBoolean(MqttServiceConstants.CALLBACK_RECONNECT, false);
		String serverURI = data.getString(MqttServiceConstants.CALLBACK_SERVER_URI);
		((MqttCallbackExtended) callback).connectComplete(reconnect, serverURI);
	}

}