Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleClick on the Customize then the Copy and Edit button so you can access the Translator and alter the code

Refer to Customizing components to see how it's done if you have not done this before.

Expand
titleUse the Annotation Window to view your sample data in the String Viewing Window

Now we are in the Translator!

Every Translator component contains a Main.lua module with a main function that is called each time a message is received or on a configured poll time.

Notice we can see our sample data (Variable named Data) passed to main functionby looking at the Annotation Windows.

If we click on the sample data in the annotations, we can view it using The string viewing window.

...

Expand
titleUse another if statement in main to test if a message should be queued or filtered out

Your main function should look like this:

This if statement is testing if the filter function returns true - the domain name equalled “interfaceware.com” - then queue the message to be processed by the next component.

See How to push messages into a queue?.

Expand
titleNow let's see our filtering in action by going through the sample data and viewing the annotations

By switching which Sample Data is being passed to main, we can see the results and test how our filter function works, by using the annotations.

Navigate to filters.lua and switch to the second sample data to see the sample message fail the condition and return false.

Expand
titleAdd custom logging to your filter to make it more comprehensive

Now that the annotations are active for the failed scenario, we can leverage them to add Custom Logging to add more visibility into the logs.

For example,

Code Block
languagelua
if domain == 'interfaceware.com' then
  return true
else 
  iguana.log('Filtered out message with: '..domain)   
  return false
end

You’re done the filter! Don’t forget to Commit and Push Changes to Git.

Now back to the Orientation!