Closed igkg closed 5 months ago
This should be relatively simple to implement yourself outside of the library (the callback is passed a MessageHandler
which accepts (Client, Message)
so you can get the client ID using Client.OptionsReader().ClientID()
. I don't see a need to change the Message
interface` here.
@MattBrittan
var messagePubHandler mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
clientReader := client.OptionsReader()
clientId := clientReader.ClientID()
clientId is the recipient client ID. I need the sender client ID.
Then you will need to include it in the message or topic. The Client ID is only used for comms between one client and the broker, it's not passed to subscribing clients (so there is no way for the receiving client to get this info). This is setout in the MQTT spec.
Okay, got it. Thanks for your reply.
Hello, We have emqx plugin and when we receive a message we save ClientID of message sender and use it next in our code. But as I see current library doesn't provide ClientID of message sender.
Could someone add a feature to get the ClientId of the sender of a message?