Accessing and Deleting a Message

I have a flow where messages containing an id, text string and a number of times to repeat comes in from an HTTP end-point. The text is converted to audio and is played over a loudspeaker with a delay before repeating. I want to add the ability to "cancel" a message that is in the loop before it repeats.

Can a new message trigger the removal of an older message that's still "active"?

What version of NR and node.js?
What platform is NR running on?
what node are you using to play the audio?
Have you looked at it's options?
have you gone to the node's github page and looked at any issues it might have?

Take a look at the delay node to only "release" one audio at a time, which would allow you to reset the queue cancelling any further audio files if you so wished. But this does assume you know how long the audio is likely to be.

node-red 0.18.7
nodejs 8.11.3

using mpg321 (via the exec node) to play audio.

I have looked at the project on GitHub mainly looking for an API call to access messages, but could not find anything. I'm thinking I need to keep a log of the "canceled" messages at the context level, but I have yet to experiment.

  1. where do you expect the audio to play - i.e. from the machine running node red or the machine that is accessing it?
  2. have you looked at any of the audio nodes?

I would have a node that adds messages to an array with a 'repeat, no repeat of delete' flag for each message.
You then have a node that reads the message

  • if the flag == delete then delete the message from the array and read the next one.
  • if the flag = no repeat, change the falg to delete and send the message to the audio node
  • if the flag - repeat jus send the meaasge to the audio node.

when the audio is done, you loop back to the node that grabs the msg from the array.

Now you could have a button that goes to the array and changes the flag and you should be all set.

Maybe check this example flow https://flows.nodered.org/flow/cea8afa28b7a93ebdc0f
Which should be easy to modify to accept a reset message

@dceejay, @zenofmud That's exactly what I ended up doing! I created a log of incoming messages, when a delete message comes in, I remove the message from the log. The player checks the log before repeating a message, if it's not in the log it deletes it. I'm a bit surprised there is not an API for accessing the messages directly, but this works. Thanks everyone.