use of net.sf.xenqtt.client.Subscription in project moleculer-java by moleculer-java.
the class MqttTransporter method subscribed.
@Override
public void subscribed(MqttClient client, Subscription[] requestedSubscriptions, Subscription[] grantedSubscriptions, boolean requestsGranted) {
for (Subscription s : grantedSubscriptions) {
String channel = s.getTopic();
Promise promise = subscriptions.remove(channel);
if (promise != null) {
promise.complete();
}
if (debug) {
logger.info("Channel \"" + channel + "\" subscribed successfully.");
}
}
}
use of net.sf.xenqtt.client.Subscription in project moleculer-java by moleculer-java.
the class MqttTransporter method subscribe.
@Override
public Promise subscribe(String channel) {
Promise promise = new Promise();
if (client != null) {
try {
client.subscribe(new Subscription[] { new Subscription(channel, qos) });
subscriptions.put(channel, promise);
} catch (Exception cause) {
promise.complete(cause);
}
} else {
promise.complete(new Throwable("Not connected!"));
}
return promise;
}
Aggregations