lib/stream.js
function Stream(options) {

  /**
   * Whether or not the Stream was initialized as
   * a single- or multi-key stream.
   *
   * @property multi
   * @type Boolean
   */
  reader(this, 'multi', !(options && options.apiKey));

  if (!this.multi) {
    options.headers = options.headers || {};
    options.headers['Zotero-API-Key'] = options.apiKey;

    delete options.apiKey;
  }

  Client.call(this, options);

  /**
   * @property retry
   * @type Object
   */
  reader(this, 'retry', {
    delay: Stream.DEFAULT_RETRY
  });

  /**
   * @property idle
   * @type Object
   */
  reader(this, 'idle', {
    ping: Stream.IDLE_TIMEOUT,
    pong: Stream.IDLE_TIMEOUT / 2
  });

  /**
   * @property subscriptions
   * @type Subscriptions
   */
  this.subscriptions = new Subscriptions();

  this.open = this.open.bind(this);
  this.opened = this.opened.bind(this);
  this.closed = this.closed.bind(this);
  this.ping = this.ping.bind(this);
  this.pong = this.pong.bind(this);
  this.receive = this.receive.bind(this);
  this.error = this.error.bind(this);

  this.open();
}
function Stream(options) {

  /**
   * Whether or not the Stream was initialized as
   * a single- or multi-key stream.
   *
   * @property multi
   * @type Boolean
   */
  reader(this, 'multi', !(options && options.apiKey));

  if (!this.multi) {
    options.headers = options.headers || {};
    options.headers['Zotero-API-Key'] = options.apiKey;

    delete options.apiKey;
  }

  Client.call(this, options);

  /**
   * @property retry
   * @type Object
   */
  reader(this, 'retry', {
    delay: Stream.DEFAULT_RETRY
  });

  /**
   * @property idle
   * @type Object
   */
  reader(this, 'idle', {
    ping: Stream.IDLE_TIMEOUT,
    pong: Stream.IDLE_TIMEOUT / 2
  });

  /**
   * @property subscriptions
   * @type Subscriptions
   */
  this.subscriptions = new Subscriptions();

  this.open = this.open.bind(this);
  this.opened = this.opened.bind(this);
  this.closed = this.closed.bind(this);
  this.ping = this.ping.bind(this);
  this.pong = this.pong.bind(this);
  this.receive = this.receive.bind(this);
  this.error = this.error.bind(this);

  this.open();
}
function Stream ( options ) { /**
   * Whether or not the Stream was initialized as
   * a single- or multi-key stream.
   *
   * @property multi
   * @type Boolean
   */ reader ( this , 'multi' , ! ( options && options . apiKey ) ) ; if ( ! this . multi ) { options . headers = options . headers || { } ; options . headers [ 'Zotero-API-Key' ] = options . apiKey ; delete options . apiKey ; } Client . call ( this , options ) ; /**
   * @property retry
   * @type Object
   */ reader ( this , 'retry' , { delay : Stream . DEFAULT_RETRY } ) ; /**
   * @property idle
   * @type Object
   */ reader ( this , 'idle' , { ping : Stream . IDLE_TIMEOUT , pong : Stream . IDLE_TIMEOUT / 2 } ) ; /**
   * @property subscriptions
   * @type Subscriptions
   */ this . subscriptions = new Subscriptions ( ) ; this . open = this . open . bind ( this ) ; this . opened = this . opened . bind ( this ) ; this . closed = this . closed . bind ( this ) ; this . ping = this . ping . bind ( this ) ; this . pong = this . pong . bind ( this ) ; this . receive = this . receive . bind ( this ) ; this . error = this . error . bind ( this ) ; this . open ( ) ; }
Connects to the Zotero Streaming API
by establishing a WebSocket connection.

@class Stream
@constructor
@extends Client

@param {Object} options
Connects to the Zotero Streaming API by establishing a WebSocket connection .