index.js
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const MODULE_NAME = 'KOMODO_SDK-PUSH-TRX.CLIENT';
const config = require('komodo-sdk/config');
const logger = require('tektrans-logger');
const uniqid = require('uniqid');
const connect = require('./connect');
const debugAllGatewaysFromConfig = global.SDK_PUSH_TRX_DEBUG_ALL_GATEWAYS_FROM_CONFIG
|| false;
const connectAll = (xidFromCaller) => {
const xid = xidFromCaller || uniqid();
const gateways = config.gateways
.filter((gateway) => !gateway.disabled
&& gateway.name
&& gateway.url
&& (gateway.url.indexOf('ws://') !== 0)
&& ((new URL(gateway.url) || {}).protocol === 'ws:'));
if (debugAllGatewaysFromConfig) {
logger.verbose(`${MODULE_NAME} 80C7AAD6: Dumping config.gateways`, {
xid,
gateways: config.gateways,
});
}
logger.verbose(`${MODULE_NAME} 79B5FEB5: Connecting to all gateways`, {
xid,
gatewayNames: gateways.map((gateway) => gateway.name),
});
gateways.forEach((gateway) => {
connect(xid, gateway);
});
};
connectAll();