Sha256: c2f64357545e08a64a963e5acc07f3e12a35b171f11e1d253d2f6e21c4158811

Contents?: true

Size: 1.32 KB

Versions: 34

Compression:

Stored size: 1.32 KB

Contents

'use strict';

var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
  debug = require('debug')('sockjs-client:utils:transport');
}

module.exports = function(availableTransports) {
  return {
    filterToEnabled: function(transportsWhitelist, info) {
      var transports = {
        main: []
      , facade: []
      };
      if (!transportsWhitelist) {
        transportsWhitelist = [];
      } else if (typeof transportsWhitelist === 'string') {
        transportsWhitelist = [transportsWhitelist];
      }

      availableTransports.forEach(function(trans) {
        if (!trans) {
          return;
        }

        if (trans.transportName === 'websocket' && info.websocket === false) {
          debug('disabled from server', 'websocket');
          return;
        }

        if (transportsWhitelist.length &&
            transportsWhitelist.indexOf(trans.transportName) === -1) {
          debug('not in whitelist', trans.transportName);
          return;
        }

        if (trans.enabled(info)) {
          debug('enabled', trans.transportName);
          transports.main.push(trans);
          if (trans.facadeTransport) {
            transports.facade.push(trans.facadeTransport);
          }
        } else {
          debug('disabled', trans.transportName);
        }
      });
      return transports;
    }
  };
};

Version data entries

34 entries across 33 versions & 12 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.18.0 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.18.2 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.16.1 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.15.2 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.18.4 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.18.1 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.14.0 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/sockjs-client/lib/utils/transport.js
tang-0.2.1 spec/tang_app/node_modules/sockjs-client/lib/utils/transport.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/sockjs-client/lib/utils/transport.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/sockjs-client/lib/utils/transport.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/sockjs-client/lib/utils/transport.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/sockjs-client/lib/utils/transport.js
tang-0.2.0 spec/tang_app/node_modules/sockjs-client/lib/utils/transport.js
tang-0.1.0 spec/tang_app/node_modules/sockjs-client/lib/utils/transport.js
tang-0.0.9 spec/tang_app/node_modules/sockjs-client/lib/utils/transport.js
enju_library-0.3.8 spec/dummy/node_modules/sockjs-client/lib/utils/transport.js
ilog-0.4.1 node_modules/sockjs-client/lib/utils/transport.js