Invalid Space ID: cfEventManager

Version 2, last updated by peter svensson at Mar 13 13:00 2007 UTC

Sample Declaration

<div id="messages1"
    impl="~019448F213F49F471a8C71268CABD6424C"
    script="http://localhost/SendMessages.js">
</div>

Input Terminals

  • trigger: (expected message type: any)

Output Terminals

  • startup_message_out :
  • triggered_message_out :

Properties

  • messages : (type: array)
  • sends_one_at_a_time

Demos that use it

  • N/A

How does it work?

This blueprint is similar to its relative, SendMessageInfotron. The difference is that this one can take an array of messages, and optionally control if they are going to be sent all together or one at a time -----


/*
 */
BLUEPRINT(
"~019448F213F49F471a8C71268CABD6424C",
[
 ["%startup", "onStartUp", 1],
 ["trigger", "onTrigger", 1]
],
[
 "startup_message_out",
 "triggered_message_out"
],
function(props)
{
  var Blueprint = function(id, props, bp_uuid)
  {
    this.__init__(id, bp_uuid);
    this._msgs = props["messages"] || [];
    this._one_at_a_time = props["sends_one_at_a_time"] || false;
    this._curr_i = 0;
  };

  Blueprint.prototype = new Infotron;

  Blueprint.prototype.onStartUp = function(msg)
  {
    this._sendMessages("startup_message_out");
  };
  
  Blueprint.prototype.onTrigger = function(msg)
  {
    this._sendMessages("triggered_message_out");
  };
  
  Blueprint.prototype._sendMessages = function(oterm)
  {
    var i;
    var n = this._msgs.length;
    
    if (!this._one_at_a_time) {
      for (i = 0; i < n; i ++) {
	this.postMessage(oterm, this._msgs[i]);
      }
    } else {
      i = this._curr_i ++;
      this.debug("_curr_i = " + this._curr_i);
      this.postMessage(oterm, this._msgs[i]);
    }
  }

  return Blueprint;
 },"Send Message");