Comparing versions 4 and 5.

ListRouterInfotron

Another message routing example

Sample Declaration

<div id="listrouter"
     impl="~01A9E6281DB91F401694F452FEB018F545"
     properties=" 'out1_match_value': '0',
                          'out2_match_value': '1',
                          'out3_match_value': '2',
                          'match_index': '0',
                          'out_value_index': '1'  "
     script="http://localhost/Alert.js">
</div>
## Input Terminals + list_in: (expected message type: list with at least two values; chosen output terminal identifier, and data to route. ## Output Terminals + out1 : arbitrary output terminals to route between. + out2 + out3 ## Properties + out1_match_value : these three are just arbitrary identifier for the output terminals. + out2_match_value + out3_match_value + match_index : This defines which position of the input array/list is parsed as the output terminal identifier. + out_value_index : This property defines the index in the input list which containes the data to send to the chosen output terminal. ## Demos that use it + map.html + multi_map.html ## How does it work? The initialization of properties tells this blueprint how to act upon incoming messages. First the three match_value proeprteis give each output terminal an identifier. This identifier is the used as part of the incoming message. The two index proeprteis define which part of the incoming message array/list is treated as output terminal identifier and which is treated as data. This is a very versatile blueprint, but not for the faint of heart. ------

BLUEPRINT(
"~01A9E6281DB91F401694F452FEB018F545",
[
 ["list_in", "onList", 10]
],
[
 "out1",
 "out2",
 "out3"
],
function(Class)
{
    Class.prototype.onList = function(msg)
    {
        var val = msg[this._i_match];

        if (val == this._match1) {
            this.postMessage("out1", msg[this._i_value]);
        } else if (val == this._match2) {
            this.postMessage("out2", msg[this._i_value]);
        } else if (val == this._match3) {
            this.postMessage("out3", msg[this._i_value]);
        }
    };

    Class.prototype._onInit = function(props)
    {
      this._match1 = props["out1_match_value"];
      this._match2 = props["out2_match_value"];
      this._match3 = props["out3_match_value"];
      this._i_match = props["match_index"] || 0;
      this._i_value = props["out_value_index"] || 0;
    }
}, "List Router");

History Key

  • New content
  • Removed content

Recent Versions

Choose two versions to compare, or click the link to view it.

  1. 5. about 1 year by slim
  2. 4. about 1 year by slim
  3. 3. about 1 year by xexamedes
  4. 2. about 1 year by xexamedes
  5. 1. about 1 year by xexamedes