MQTTX icon indicating copy to clipboard operation
MQTTX copied to clipboard

[Feature] Script function improvement

Open magixyu opened this issue 3 years ago • 3 comments

Describe the problem you Confuse

For the detail of the scripting using. Is it possible to program a script: when receive a msg from a channel, publish msg back to another topic.

More detail (optional)

Add any other context or screenshots.

magixyu avatar Jul 20 '21 07:07 magixyu

@magixyu If I understand correctly, You want to use a script to send messages to other connections.

But sorry,MQTT X don't support cross connection message publish now.

oceanlvr avatar Jul 20 '21 08:07 oceanlvr

It is a good idea that script could handle different connections, such as get some message send message to test/1 by script. Maybe it could be like this:


function handlePayload(value) {
  if(value.msg === 1024){
    MqttxApi.pub('test/1', "hello world")  //send hello world to test/1 topic 
  }
  return value.msg // send value.message to current topic
}

execute(handlePayload)

@ysfscream

oceanlvr avatar Jul 20 '21 08:07 oceanlvr

I would like to send to the same connection but different topic. Like I receive an message from /topic1, then the tool automatically send back to /topic1_reply with certain content.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: @.> Sent: 2021年7月20日 16:51 To: @.> Cc: Tristan @.>; @.> Subject: Re: [emqx/MQTTX] [Help] the title of Help_Want report (#635)

@magixyuhttps://github.com/magixyu If I understand correctly, You want to use a script to send messages to other connections.

But sorry,MQTT X don't support cross connection message publish now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/emqx/MQTTX/issues/635#issuecomment-883219686, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAMOZB7W3NW4D2RTZ5AT7F3TYU2JDANCNFSM5AVH5WWQ.

magixyu avatar Jul 20 '21 10:07 magixyu