可以MQTT被用来实现请求/响应行为行为、MQTT

2023-09-07 15:16:59 作者:无名指的等待

我们计划使用MQTT来提供我们的服务器消息到Android设备 我们决定去与开源服务器mosquitto。

We are planning to use MQTT to deliver messages from our server to an android devices we decided to go with the open source server mosquitto.

在大多数情况下,这已经足够了。(发布/订阅) 但我们有一个情况下,客户端需要发送的参数,并得到来自服务器的响应。 我知道直接的办法就是去与HTTP(Servlet的举例)。 但我们可以做到这一点使用MQTT因为这将意味着更低的带宽消耗用户?

in most of the cases this is enough.(Publishing / subscribing ) but we have a cases where the client need to send parameters and get response from the server. i know the direct approach is to go with Http (Servlets for example) . but can we achieve this using MQTT since it would mean lower bandwidth consumption to the user ?

推荐答案

是的,它只是需要仔细设计你的话题结构。作为一个非常简单的例子,你可以发布到控制/<客户端ID> /请求和订阅控制/<客户端ID> /响应

Yes, it just requires careful design of your topic structure. As a very simple example, you could publish to control/<client id>/request and subscribe to control/<client id>/response