vert-x3 / vertx-mqtt

Vert.x MQTT
Apache License 2.0
184 stars 86 forks source link

Unable to unsubscribe from multiple topics at once #199

Open ctron opened 3 years ago

ctron commented 3 years ago

Describe the feature

Currently there is an unsubscribe method, which only allows to unsubscribe from a single topic. However, with MQTT you can unsubscribe from multiple topic filters at the same time.

Use cases

Unsubscribe from multiple topics, in a single message.

chenzhiguo commented 3 years ago

Yeah, MQTT topic filters are a very important feature, look at the source implementation, it doesn't seem to do this specifically, right?

tsegismont commented 2 years ago

@ctron would you like to contribute?

ctron commented 2 years ago

I could draft up a PR. However I am not sure I can find the time to follow up on this to get it merged. I think this should come from the project.

SivaAkiro commented 2 years ago

Hi @vietj i would like to contribute. Let me know what is the process.

SivaAkiro commented 2 years ago

MqttClientImpl Class.

@Override public Future unsubscribe(List topics) {

MqttFixedHeader fixedHeader = new MqttFixedHeader(
  MqttMessageType.UNSUBSCRIBE,
  false,
  AT_LEAST_ONCE,
  false,
  0);

MqttMessageIdVariableHeader variableHeader = new MqttMessageIdAndPropertiesVariableHeader(
  nextMessageId(), MqttProperties.NO_PROPERTIES);

MqttUnsubscribePayload payload = new MqttUnsubscribePayload(topics);

io.netty.handler.codec.mqtt.MqttMessage unsubscribe = MqttMessageFactory.newMessage(fixedHeader,
  variableHeader, payload);

this.write(unsubscribe);

return ctx.succeededFuture(variableHeader.messageId());

}

Changed the corresponding other classes also.

Tested the same with sample server and client.

vietj commented 2 years ago

you can read these

happy to have a PR @SivaAkiro