source: trip-planner-front/node_modules/sockjs-client/lib/utils/transport.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2
3var debug = function() {};
4if (process.env.NODE_ENV !== 'production') {
5 debug = require('debug')('sockjs-client:utils:transport');
6}
7
8module.exports = function(availableTransports) {
9 return {
10 filterToEnabled: function(transportsWhitelist, info) {
11 var transports = {
12 main: []
13 , facade: []
14 };
15 if (!transportsWhitelist) {
16 transportsWhitelist = [];
17 } else if (typeof transportsWhitelist === 'string') {
18 transportsWhitelist = [transportsWhitelist];
19 }
20
21 availableTransports.forEach(function(trans) {
22 if (!trans) {
23 return;
24 }
25
26 if (trans.transportName === 'websocket' && info.websocket === false) {
27 debug('disabled from server', 'websocket');
28 return;
29 }
30
31 if (transportsWhitelist.length &&
32 transportsWhitelist.indexOf(trans.transportName) === -1) {
33 debug('not in whitelist', trans.transportName);
34 return;
35 }
36
37 if (trans.enabled(info)) {
38 debug('enabled', trans.transportName);
39 transports.main.push(trans);
40 if (trans.facadeTransport) {
41 transports.facade.push(trans.facadeTransport);
42 }
43 } else {
44 debug('disabled', trans.transportName);
45 }
46 });
47 return transports;
48 }
49 };
50};
Note: See TracBrowser for help on using the repository browser.