Another message routing example
<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>
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");