lib/Conversation.js
function Conversation (config) {
  if (!(this instanceof Conversation)) {
    throw new SyntaxError('Constructor must be called with the new operator');
  }

  // public properties
  this.id =       config && config.id       || uuid.v4();
  this.self =     config && config.self     || null;
  this.other =    config && config.other    || null;
  this.context =  config && config.context  || {};

  // private properties
  this._send =    config && config.send     || null;
  this._inbox = [];     // queue with received but not yet picked messages
  this._receivers = []; // queue with handlers waiting for a new message
}
function Conversation (config) {
  if (!(this instanceof Conversation)) {
    throw new SyntaxError('Constructor must be called with the new operator');
  }

  // public properties
  this.id =       config && config.id       || uuid.v4();
  this.self =     config && config.self     || null;
  this.other =    config && config.other    || null;
  this.context =  config && config.context  || {};

  // private properties
  this._send =    config && config.send     || null;
  this._inbox = [];     // queue with received but not yet picked messages
  this._receivers = []; // queue with handlers waiting for a new message
}
function Conversation ( config ) { if ( ! ( this instanceof Conversation ) ) { throw new SyntaxError ( 'Constructor must be called with the new operator' ) ; } // public properties this . id = config && config . id || uuid . v4 ( ) ; this . self = config && config . self || null ; this . other = config && config . other || null ; this . context = config && config . context || { } ; // private properties this . _send = config && config . send || null ; this . _inbox = [ ] ; // queue with received but not yet picked messages this . _receivers = [ ] ; // queue with handlers waiting for a new message }
A conversation
Holds meta data for a conversation between two peers
@param {Object} [config] Configuration options:
{string} [id]      A unique id for the conversation. If not provided, a uuid is generated
{string} self      Id of the peer on this side of the conversation
{string} other     Id of the peer on the other side of the conversation
{Object} [context] Context passed with all callbacks of the conversation
{function(to: string, message: *): Promise} send   Function to send a message
@constructor
A conversation Holds meta data for a conversation between two peers