src/priv.ps.js
function send(msg) {
    switch(ps.readyState) {
      case 0: // CONNECTING
        setTimeout(function () { send(msg); }, 1000);
        break;
      case 2: // CLOSING
      case 3: // CLOSED
        _event('dev', 'pubsub - reconnect: send() - closing/closed state');
        connect();
        setTimeout(function () { send(msg); }, 2000);
        break;
      case 1: // OPEN
        try {
          ps.send(msg);
        } catch (err) {
          console.error(err);
          setTimeout(function () { send(msg); }, 1500);
        }
        break;
      default:
        break;
		}
  }
function send(msg) {
    switch(ps.readyState) {
      case 0: // CONNECTING
        setTimeout(function () { send(msg); }, 1000);
        break;
      case 2: // CLOSING
      case 3: // CLOSED
        _event('dev', 'pubsub - reconnect: send() - closing/closed state');
        connect();
        setTimeout(function () { send(msg); }, 2000);
        break;
      case 1: // OPEN
        try {
          ps.send(msg);
        } catch (err) {
          console.error(err);
          setTimeout(function () { send(msg); }, 1500);
        }
        break;
      default:
        break;
		}
  }
function send ( msg ) { switch ( ps . readyState ) { case 0 : // CONNECTING setTimeout ( function ( ) { send ( msg ) ; } , 1000 ) ; break ; case 2 : // CLOSING case 3 : // CLOSED _event ( 'dev' , 'pubsub - reconnect: send() - closing/closed state' ) ; connect ( ) ; setTimeout ( function ( ) { send ( msg ) ; } , 2000 ) ; break ; case 1 : // OPEN try { ps . send ( msg ) ; } catch ( err ) { console . error ( err ) ; setTimeout ( function ( ) { send ( msg ) ; } , 1500 ) ; } break ; default : break ; } }
this provides some preventative error handling because the pubsub edge seems to be unstable
this provides some preventative error handling because the pubsub edge seems to be unstable