lib/module/BabbleModule.js
function BabbleModule(agent, options) {
  // create a new babbler
  var babbler = babble.babbler(agent.id);
  babbler.connect({
    connect: function (params) {},
    disconnect: function(token) {},
    send: function (to, message) {
      agent.send(to, message);
    }
  });
  this.babbler = babbler;

  // create a receive function for the agent
  var receiveOriginal = agent._receive;
  this._receive = function (from, message) {
    babbler._receive(message);
    // TODO: only propagate to receiveOriginal if the message is not handled by the babbler
    return receiveOriginal.call(agent, from, message);
  };
}
function BabbleModule(agent, options) {
  // create a new babbler
  var babbler = babble.babbler(agent.id);
  babbler.connect({
    connect: function (params) {},
    disconnect: function(token) {},
    send: function (to, message) {
      agent.send(to, message);
    }
  });
  this.babbler = babbler;

  // create a receive function for the agent
  var receiveOriginal = agent._receive;
  this._receive = function (from, message) {
    babbler._receive(message);
    // TODO: only propagate to receiveOriginal if the message is not handled by the babbler
    return receiveOriginal.call(agent, from, message);
  };
}
function BabbleModule ( agent , options ) { // create a new babbler var babbler = babble . babbler ( agent . id ) ; babbler . connect ( { connect : function ( params ) { } , disconnect : function ( token ) { } , send : function ( to , message ) { agent . send ( to , message ) ; } } ) ; this . babbler = babbler ; // create a receive function for the agent var receiveOriginal = agent . _receive ; this . _receive = function ( from , message ) { babbler . _receive ( message ) ; // TODO: only propagate to receiveOriginal if the message is not handled by the babbler return receiveOriginal . call ( agent , from , message ) ; } ; }
Create a Babble module for an agent.
The agents _receive function is wrapped into a new handler.
Creates a Babble instance with function `ask`, `tell`, `listen`, `listenOnce`
@param {Agent} agent
@param {Object} [options]   Optional parameters. Not applicable for BabbleModule
@constructor
Create a Babble module for an agent . The agents _receive function is wrapped into a new handler . Creates a Babble instance with function ask tell listen listenOnce