Comparing versions 1 and 2.

SendMessagesInfotron


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");

History Key

  • New content
  • Removed content

Recent Versions

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

  1. 2. about 1 year by xexamedes
  2. 1. about 1 year by xexamedes