问题
I am trying to get topic of mqtt client, i searched in google, i couldn't find right one.
for example, from mqtt client, publish one message,consider server topic is 'topicOfServer' and client topic is 'topicOfClient'.
client.publish('topicOfServer','hi server');
server will get 'hi server' message. but how do server knows that message came from which client ex: 'topicOfClient'
回答1:
You seam to be confusing a couple of things here
- Topics are just "addresses" that any MQTT client can send a message to, they are not owned in any way by any client.
- There is no way to determine which MQTT client published any message from another MQTT client unless the sender encodes that information somewhere in the message payload.
来源:https://stackoverflow.com/questions/42668325/how-to-get-topic-of-mqtt-client-in-websocket-server