How to get topic of mqtt client in websocket serve

2019-09-15 04:27发布

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条回答
smile是对你的礼貌
2楼-- · 2019-09-15 04:57

You seam to be confusing a couple of things here

  1. Topics are just "addresses" that any MQTT client can send a message to, they are not owned in any way by any client.
  2. 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.
查看更多
登录 后发表回答