-
Notifications
You must be signed in to change notification settings - Fork 292
Description
Hi,
I'm currently using Mochi MQTT as an embedded broker and writing a custom hook to handle bulk messages.
In this hook, I intercept messages sent to the topic bulk and split them into separate messages, publishing them to sensor/... topics. Everything works fine, except for one missing feature: I would like to publish to a topic while excluding the client who sent the original message.
Here’s what I'm trying to do:
- Client A publishes to
bulkwith a JSON payload (e.g.{ "temp": 22, "hum": 60 }) - My hook publishes:
sensor/temp→22sensor/hum→60
- But I want to avoid sending those messages back to client A.
So far, I’ve tried:
- Using
srv.Publish(...): works, but always delivers to all subscribers, including the source. - Using
InjectPacket(...)with a fake client, but it's difficult to construct a valid*mqtt.Clientfrom outside the package (some fields are private, some required interfaces are internal).
Question:
Is there currently a supported way to publish a message to a topic and exclude one or more clients from receiving it?
If not, would you consider adding an API like:
server.PublishExclude(topic string, payload []byte, retain bool, qos byte, excludeIDs []string)or perhaps allow InjectPacket() to accept a special internal "server" client that bypasses the sender?
Thanks a lot for the great work on this broker — it's lightweight, performant, and very developer-friendly 🙌
Best regards,