emqx / MQTTX

A Powerful and All-in-One MQTT 5.0 client toolbox for Desktop, CLI and WebSocket.
https://mqttx.app
Apache License 2.0
3.82k stars 438 forks source link

[Feature] Publish Snippets #584

Open apprentice1988 opened 3 years ago

apprentice1988 commented 3 years ago

Motivation

Like Postman, I hope Mqttx have a snippets to store a list of [topic and message]. Then I can mock device different kinds of message quickly.

Detailed design

In the left bar add a [Snippets] below [Scripts] to manage my snippets. I can add messages with topics in this section. Then in the [Connection] tab, I can select a snippet to send if i don't want to edit message manually.

ysfscream commented 3 years ago

@apprentice1988 Hi, thanks! this is a good idea💡 We will consider whether to add this feature.

  1. But the current historical Topic and Payload functions should help you temporarily. When you publish successfully, Payload and Topic will have history records, click the button in the lower right corner to view, avoid the trouble of manual input.

image

  1. In the script page, the fixed payload value is returned in the function, which can also avoid this problem

image

apprentice1988 commented 3 years ago

I hope there is a way:

  1. import SyncApi file to snippets and can transfer many messages
  2. pick one message can mock data and send
  3. I will subscribe the channel/topic in my server I am not sure if it's a common use path.
ysfscream commented 3 years ago

OK! My current understanding is that you need a functional mock, the data from the API? Because I don’t quite understand the specific purpose of the SyncAPI file, but the script function provides some functions for generating mock data, you can refer to this article:

https://www.emqx.io/blog/mqttx-script-function-tutorial