/** * Requests the server to unsubscribe the client from one or more topics. * * @param topic * one or more topics to unsubscribe from. Each topic must match * one specified on an earlier subscription. * @return token used to track and wait for the unsubscribe to complete. The * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override public IMqttToken unsubscribe(String[] topic) throws MqttException { return unsubscribe(topic, null, null); }
/** * Requests the server unsubscribe the client from a topic. * * @param topic * the topic to unsubscribe from. It must match a topic specified * on an earlier subscribe. * @return token used to track and wait for the unsubscribe to complete. The * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override public IMqttToken unsubscribe(String topic) throws MqttException { return unsubscribe(topic, null, null); }
public void unsubscribe (Subscription subscription) throws MqttException { if(subscriptions.containsKey(subscription.getTopic())){ this.getClient().unsubscribe(subscription.getTopic()); subscriptions.remove(subscription.getTopic()); Persistence persistence = new Persistence(context); persistence.deleteSubscription(subscription); } }
/** * Requests the server unsubscribe the client from a topic. * * @param topic * the topic to unsubscribe from. It must match a topic specified * on an earlier subscribe. * @return token used to track and wait for the unsubscribe to complete. The * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override public IMqttToken unsubscribe(String topic) throws MqttException { return unsubscribe(topic, null, null); }
/** * Requests the server to unsubscribe the client from one or more topics. * * @param topic * one or more topics to unsubscribe from. Each topic must match * one specified on an earlier subscription. * @return token used to track and wait for the unsubscribe to complete. The * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override public IMqttToken unsubscribe(String[] topic) throws MqttException { return unsubscribe(topic, null, null); }
/** * Requests the server to unsubscribe the client from one or more topics. * * @param topic * one or more topics to unsubscribe from. Each topic must match * one specified on an earlier subscription. * @return token used to track and wait for the unsubscribe to complete. The * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override public IMqttToken unsubscribe(String[] topic) throws MqttException { return unsubscribe(topic, null, null); }
/** * Requests the server unsubscribe the client from a topic. * * @param topic * the topic to unsubscribe from. It must match a topic specified * on an earlier subscribe. * @return token used to track and wait for the unsubscribe to complete. The * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override public IMqttToken unsubscribe(String topic) throws MqttException { return unsubscribe(topic, null, null); }
public void unsubscribe(String topic) { if (mMqttClient != null && mMqqtClientStatus == MqqtConnectionStatus.CONNECTED && topic != null) { try { Log.d(TAG, "Mqtt: unsubscribe from " + topic); mMqttClient.unsubscribe(topic); } catch (MqttException e) { Log.e(TAG, "Mqtt:x unsubscribe error: ", e); } } }
@Override public void unsubscribe(final String topic) { try { topics.remove(topic); mMqttAndroidClient.unsubscribe(topic, null, new IMqttActionListener() { @Override public void onSuccess(IMqttToken asyncActionToken) { Log.v(TAG, "Subscription Infrastructure: Disconnected from topic [" + topic +"]"); } @Override public void onFailure(IMqttToken asyncActionToken, Throwable exception) { Log.v(TAG, "Subscription Infrastructure: Errror [" + exception + "] when disconnecting from topic [" + topic +"]"); } }); } catch (Exception e) { Log.v(TAG, "Unsubscribe failed at the MQTT level [" + e +"]"); } }
public void unSubscribe(@NonNull MqttAndroidClient client, @NonNull final String topic) throws MqttException { IMqttToken token = client.unsubscribe(topic); token.setActionCallback(new IMqttActionListener() { @Override public void onSuccess(IMqttToken iMqttToken) { Log.d(TAG, "UnSubscribe Successfully " + topic); } @Override public void onFailure(IMqttToken iMqttToken, Throwable throwable) { Log.e(TAG, "UnSubscribe Failed " + topic); } }); }
public void unSubscribe(BrokerEntity brokerEntity, String topic){ MqttAndroidClient mqttAndroidClient = clients.get(brokerEntity.getId()); if(mqttAndroidClient!=null){ try { mqttAndroidClient.unsubscribe(topic); } catch (MqttException e) { e.printStackTrace(); } } }
final String topic = "foo/bar"; try { IMqttToken unsubToken = mqttAndroidClient.unsubscribe(topic); unsubToken.setActionCallback(new IMqttActionListener() { @Override
mClient.unsubscribe(topic, mContext, listener); } catch (MqttException e) { e.printStackTrace();