function connected(app) {
            return new Promise(function(resolve, reject) {
              if (app.rest) {
                return resolve();
              }

              var socket = app.io || app.primus;

              if (!socket) {
                return reject(new Error('It looks like no client connection has been configured.'));
              }

              // If one of those events happens before `connect` the promise will be rejected
              // If it happens after, it will do nothing (since Promises can only resolve once)
              socket.once('disconnect', reject);
              socket.once('close', reject);

              // If the socket is not connected yet we have to wait for the `connect` event
              if ((app.io && !socket.connected) || (app.primus && socket.readyState !== 3)) {
                socket.once('connect', function() {
                  return resolve(socket);
                });
              } else {
                resolve(socket);
              }
            });
          }
// Returns a promise that resolves when the socket is connected
Returns a promise that resolves when the socket is connected
Returns a promise that resolves when the socket is connected
function connected(app) {
            return new Promise(function(resolve, reject) {
              if (app.rest) {
                return resolve();
              }
              var socket = app.io || app.primus;
              if (!socket) {
                return reject(new Error('It looks like no client connection has been configured.'));
              }
              socket.once('disconnect', reject);
              socket.once('close', reject);
              if ((app.io && !socket.connected) || (app.primus && socket.readyState !== 3)) {
                socket.once('connect', function() {
                  return resolve(socket);
                });
              } else {
                resolve(socket);
              }
            });
          }
function connected ( app ) { return new Promise ( function ( resolve , reject ) { if ( app . rest ) { return resolve ( ) ; } var socket = app . io || app . primus ; if ( ! socket ) { return reject ( new Error ( 'It looks like no client connection has been configured.' ) ) ; } socket . once ( 'disconnect' , reject ) ; socket . once ( 'close' , reject ) ; if ( ( app . io && ! socket . connected ) || ( app . primus && socket . readyState !== 3 ) ) { socket . once ( 'connect' , function ( ) { return resolve ( socket ) ; } ) ; } else { resolve ( socket ) ; } } ) ; }
Returns a promise that resolves when the socket is connected
Returns a promise that resolves when the socket is connected
// If one of those events happens before `connect` the promise will be rejected // If it happens after, it will do nothing (since Promises can only resolve once) // If the socket is not connected yet we have to wait for the `connect` event