lib/spike/index.js
function (oldBin, newBin) {

    if (!newBin || !newBin.url) {
      // FIXME this is just patching a problem, the source of which I'm not sure
      console.error('spike/index.js#bump-revision - missing newBin', newBin);
      return;
    }

    var oldSession = utils.sessionForBin(oldBin),
        oldKey = utils.keyForBin(oldBin),
        newSession = utils.sessionForBin(newBin, true),
        newKey = utils.keyForBin(newBin);

    if (!oldSession) { return; }

    // Move connections from one session to another
    oldSession.res.forEach(function (res) {
      // Add the connection to the new session's list
      newSession.res.push(res);
      // Upgrade the connection with the new bin
      res.req.bin = newBin;
      // Tell the client to bump their revision
      res.write(utils.makeEvent('bump-revision', newKey));
      if (res.ajax) {
        // lets older browsers finish their xhr request
        res.end();
        res.req.emit('close');
      }
      return false;
    });

    // There should be no more connections to this bin, so byebye!
    oldSession.res = [];
    delete sessions[oldKey];

  }
function (oldBin, newBin) {

    if (!newBin || !newBin.url) {
      // FIXME this is just patching a problem, the source of which I'm not sure
      console.error('spike/index.js#bump-revision - missing newBin', newBin);
      return;
    }

    var oldSession = utils.sessionForBin(oldBin),
        oldKey = utils.keyForBin(oldBin),
        newSession = utils.sessionForBin(newBin, true),
        newKey = utils.keyForBin(newBin);

    if (!oldSession) { return; }

    // Move connections from one session to another
    oldSession.res.forEach(function (res) {
      // Add the connection to the new session's list
      newSession.res.push(res);
      // Upgrade the connection with the new bin
      res.req.bin = newBin;
      // Tell the client to bump their revision
      res.write(utils.makeEvent('bump-revision', newKey));
      if (res.ajax) {
        // lets older browsers finish their xhr request
        res.end();
        res.req.emit('close');
      }
      return false;
    });

    // There should be no more connections to this bin, so byebye!
    oldSession.res = [];
    delete sessions[oldKey];

  }
function ( oldBin , newBin ) { if ( ! newBin || ! newBin . url ) { // FIXME this is just patching a problem, the source of which I'm not sure console . error ( 'spike/index.js#bump-revision - missing newBin' , newBin ) ; return ; } var oldSession = utils . sessionForBin ( oldBin ) , oldKey = utils . keyForBin ( oldBin ) , newSession = utils . sessionForBin ( newBin , true ) , newKey = utils . keyForBin ( newBin ) ; if ( ! oldSession ) { return ; } // Move connections from one session to another oldSession . res . forEach ( function ( res ) { // Add the connection to the new session's list newSession . res . push ( res ) ; // Upgrade the connection with the new bin res . req . bin = newBin ; // Tell the client to bump their revision res . write ( utils . makeEvent ( 'bump-revision' , newKey ) ) ; if ( res . ajax ) { // lets older browsers finish their xhr request res . end ( ) ; res . req . emit ( 'close' ) ; } return false ; } ) ; // There should be no more connections to this bin, so byebye! oldSession . res = [ ] ; delete sessions [ oldKey ] ; }
Update spikes when a new revision is created.
Update spikes when a new revision is created .