api_connect_nodejs 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/conf/settings.ini +19 -19
- package/enums/actionType.js +10 -10
- package/enums/assetType.js +25 -25
- package/enums/chartExchangeType.js +15 -15
- package/enums/chartType.js +13 -13
- package/enums/eodIntervalType.js +11 -11
- package/enums/exchangeType.js +14 -14
- package/enums/intradayIntervalType.js +14 -14
- package/enums/marketCapType.js +12 -12
- package/enums/orderType.js +21 -21
- package/enums/productType.js +24 -24
- package/enums/segementsType.js +13 -13
- package/enums/streamingConstants.js +11 -11
- package/enums/termsType.js +12 -12
- package/enums/validity.js +22 -22
- package/index.js +3 -3
- package/package.json +25 -25
- package/src/apiConnect.js +2430 -2424
- package/src/apiUtils.js +129 -129
- package/src/chart.js +258 -258
- package/src/config.js +326 -326
- package/src/feed/feed.js +139 -139
- package/src/feed/liveNewsFeed.js +112 -112
- package/src/feed/ordersFeed.js +124 -124
- package/src/feed/quotesFeed.js +121 -121
- package/src/http.js +197 -197
- package/src/iniparser.js +42 -42
- package/src/liveNews.js +362 -362
- package/src/logger.js +16 -16
- package/src/order.js +48 -48
- package/src/researchCalls.js +175 -175
- package/src/watchlist.js +378 -378
- package/validations/apiConnectValidator.js +508 -508
- package/validations/chartValidator.js +85 -85
- package/validations/feedStreamerValidator.js +68 -68
- package/validations/liveNewsValidator.js +60 -60
- package/validations/researchCallsValidator.js +86 -86
- package/validations/watchlistValidator.js +60 -60
package/src/feed/feed.js
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
const net = require("net");
|
|
2
|
-
const configData = require("../iniparser");
|
|
3
|
-
const log4js = require("../logger");
|
|
4
|
-
const streamingConstants = require("../../enums/streamingConstants");
|
|
5
|
-
class Feed {
|
|
6
|
-
/**
|
|
7
|
-
* Streamer
|
|
8
|
-
*
|
|
9
|
-
* To subscribe to the streamer, Create the single instance of this mentioning `callback` method. After successsful subscription, `callback` method will be called whenever packet is available at the streamer.
|
|
10
|
-
* @param {string} userid User ID
|
|
11
|
-
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
12
|
-
* @param {boolean} subscribe_order
|
|
13
|
-
* @param {boolean} subscribe_quote
|
|
14
|
-
*/
|
|
15
|
-
constructor() {
|
|
16
|
-
this.sock = new net.Socket();
|
|
17
|
-
this.status = false;
|
|
18
|
-
this.init();
|
|
19
|
-
this.requestsList = {};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
init = () => {
|
|
23
|
-
this.connect();
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
connect = () => {
|
|
27
|
-
const hostName = configData.hostName;
|
|
28
|
-
const port = configData.port;
|
|
29
|
-
try {
|
|
30
|
-
this.sock.connect(port, hostName, () => {
|
|
31
|
-
this.clearIntervalConnect();
|
|
32
|
-
console.log("connected to server!");
|
|
33
|
-
log4js.debug("connected to server!");
|
|
34
|
-
});
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.log("connect error is " + error);
|
|
37
|
-
log4js.debug("connect error is " + error);
|
|
38
|
-
this.reconnect();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
clearIntervalConnect = () => {
|
|
43
|
-
if (false === this.status) return;
|
|
44
|
-
clearInterval(this.status);
|
|
45
|
-
this.status = false;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
reconnect = () => {
|
|
49
|
-
console.log("reconnecting...");
|
|
50
|
-
log4js.debug("reconnecting...");
|
|
51
|
-
|
|
52
|
-
if (this.status) return;
|
|
53
|
-
this.status = setInterval(() => {
|
|
54
|
-
this.sock.removeAllListeners();
|
|
55
|
-
this.connect();
|
|
56
|
-
}, 3000);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
subsribe = (streamingConstants, request, callBack) => {
|
|
60
|
-
const requestObj = {
|
|
61
|
-
request: request,
|
|
62
|
-
callback: callBack,
|
|
63
|
-
};
|
|
64
|
-
this.requestsList[streamingConstants] = requestObj;
|
|
65
|
-
this.readWriteStreamData(requestObj);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
unsubsribe = (streamingConstants, request) => {
|
|
69
|
-
const requestObj = {
|
|
70
|
-
request: request,
|
|
71
|
-
callback: this.requestsList[streamingConstants].callback,
|
|
72
|
-
};
|
|
73
|
-
this.readWriteStreamData(requestObj);
|
|
74
|
-
delete this.requestsList[streamingConstants];
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
readWriteStreamData = (requestObj) => {
|
|
78
|
-
try {
|
|
79
|
-
this.sock.write(JSON.stringify(requestObj.request) + "\n");
|
|
80
|
-
this.sock.on("data", (data) => {
|
|
81
|
-
try {
|
|
82
|
-
let result = data.toString();
|
|
83
|
-
if (result) {
|
|
84
|
-
if (
|
|
85
|
-
result.match(new RegExp("orderFiler", "g")) &&
|
|
86
|
-
result.match(new RegExp("orderFiler", "g")).length > 0
|
|
87
|
-
) {
|
|
88
|
-
let callbackMethod =
|
|
89
|
-
this.requestsList[streamingConstants.ORDER_STREAM_REQ_CODE][
|
|
90
|
-
"callback"
|
|
91
|
-
];
|
|
92
|
-
callbackMethod(null, result, null);
|
|
93
|
-
} else if (
|
|
94
|
-
result.match(new RegExp("quote3", "g")) &&
|
|
95
|
-
result.match(new RegExp("quote3", "g")).length > 0
|
|
96
|
-
) {
|
|
97
|
-
let callbackMethod =
|
|
98
|
-
this.requestsList[streamingConstants.QUOTE_SREAM_REQ_CODE][
|
|
99
|
-
"callback"
|
|
100
|
-
];
|
|
101
|
-
callbackMethod(null, result, null);
|
|
102
|
-
} else if (
|
|
103
|
-
result.match(new RegExp("news", "g")) &&
|
|
104
|
-
result.match(new RegExp("news", "g")).length > 0
|
|
105
|
-
) {
|
|
106
|
-
let callbackMethod =
|
|
107
|
-
this.requestsList[streamingConstants.LIVENEWS_STREAM_REQ_CODE][
|
|
108
|
-
"callback"
|
|
109
|
-
];
|
|
110
|
-
callbackMethod(null, result, null);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
} catch (error) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
this.sock.on("end", (val) => {
|
|
119
|
-
console.log("Connection ended ");
|
|
120
|
-
this.reconnect();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
this.sock.on("error", (err) => {
|
|
124
|
-
log4js.debug("connection error " + err);
|
|
125
|
-
requestObj.callback(err, null, null);
|
|
126
|
-
this.reconnect();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
this.sock.on("close", (val) => {
|
|
130
|
-
log4js.debug("connection closed " + val);
|
|
131
|
-
this.reconnect();
|
|
132
|
-
});
|
|
133
|
-
} catch (error) {
|
|
134
|
-
console.log({ error });
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
module.exports = Feed;
|
|
1
|
+
const net = require("net");
|
|
2
|
+
const configData = require("../iniparser");
|
|
3
|
+
const log4js = require("../logger");
|
|
4
|
+
const streamingConstants = require("../../enums/streamingConstants");
|
|
5
|
+
class Feed {
|
|
6
|
+
/**
|
|
7
|
+
* Streamer
|
|
8
|
+
*
|
|
9
|
+
* To subscribe to the streamer, Create the single instance of this mentioning `callback` method. After successsful subscription, `callback` method will be called whenever packet is available at the streamer.
|
|
10
|
+
* @param {string} userid User ID
|
|
11
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
12
|
+
* @param {boolean} subscribe_order
|
|
13
|
+
* @param {boolean} subscribe_quote
|
|
14
|
+
*/
|
|
15
|
+
constructor() {
|
|
16
|
+
this.sock = new net.Socket();
|
|
17
|
+
this.status = false;
|
|
18
|
+
this.init();
|
|
19
|
+
this.requestsList = {};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
init = () => {
|
|
23
|
+
this.connect();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
connect = () => {
|
|
27
|
+
const hostName = configData.hostName;
|
|
28
|
+
const port = configData.port;
|
|
29
|
+
try {
|
|
30
|
+
this.sock.connect(port, hostName, () => {
|
|
31
|
+
this.clearIntervalConnect();
|
|
32
|
+
console.log("connected to server!");
|
|
33
|
+
log4js.debug("connected to server!");
|
|
34
|
+
});
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.log("connect error is " + error);
|
|
37
|
+
log4js.debug("connect error is " + error);
|
|
38
|
+
this.reconnect();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
clearIntervalConnect = () => {
|
|
43
|
+
if (false === this.status) return;
|
|
44
|
+
clearInterval(this.status);
|
|
45
|
+
this.status = false;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
reconnect = () => {
|
|
49
|
+
console.log("reconnecting...");
|
|
50
|
+
log4js.debug("reconnecting...");
|
|
51
|
+
|
|
52
|
+
if (this.status) return;
|
|
53
|
+
this.status = setInterval(() => {
|
|
54
|
+
this.sock.removeAllListeners();
|
|
55
|
+
this.connect();
|
|
56
|
+
}, 3000);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
subsribe = (streamingConstants, request, callBack) => {
|
|
60
|
+
const requestObj = {
|
|
61
|
+
request: request,
|
|
62
|
+
callback: callBack,
|
|
63
|
+
};
|
|
64
|
+
this.requestsList[streamingConstants] = requestObj;
|
|
65
|
+
this.readWriteStreamData(requestObj);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
unsubsribe = (streamingConstants, request) => {
|
|
69
|
+
const requestObj = {
|
|
70
|
+
request: request,
|
|
71
|
+
callback: this.requestsList[streamingConstants].callback,
|
|
72
|
+
};
|
|
73
|
+
this.readWriteStreamData(requestObj);
|
|
74
|
+
delete this.requestsList[streamingConstants];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
readWriteStreamData = (requestObj) => {
|
|
78
|
+
try {
|
|
79
|
+
this.sock.write(JSON.stringify(requestObj.request) + "\n");
|
|
80
|
+
this.sock.on("data", (data) => {
|
|
81
|
+
try {
|
|
82
|
+
let result = data.toString();
|
|
83
|
+
if (result) {
|
|
84
|
+
if (
|
|
85
|
+
result.match(new RegExp("orderFiler", "g")) &&
|
|
86
|
+
result.match(new RegExp("orderFiler", "g")).length > 0
|
|
87
|
+
) {
|
|
88
|
+
let callbackMethod =
|
|
89
|
+
this.requestsList[streamingConstants.ORDER_STREAM_REQ_CODE][
|
|
90
|
+
"callback"
|
|
91
|
+
];
|
|
92
|
+
callbackMethod(null, result, null);
|
|
93
|
+
} else if (
|
|
94
|
+
result.match(new RegExp("quote3", "g")) &&
|
|
95
|
+
result.match(new RegExp("quote3", "g")).length > 0
|
|
96
|
+
) {
|
|
97
|
+
let callbackMethod =
|
|
98
|
+
this.requestsList[streamingConstants.QUOTE_SREAM_REQ_CODE][
|
|
99
|
+
"callback"
|
|
100
|
+
];
|
|
101
|
+
callbackMethod(null, result, null);
|
|
102
|
+
} else if (
|
|
103
|
+
result.match(new RegExp("news", "g")) &&
|
|
104
|
+
result.match(new RegExp("news", "g")).length > 0
|
|
105
|
+
) {
|
|
106
|
+
let callbackMethod =
|
|
107
|
+
this.requestsList[streamingConstants.LIVENEWS_STREAM_REQ_CODE][
|
|
108
|
+
"callback"
|
|
109
|
+
];
|
|
110
|
+
callbackMethod(null, result, null);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.sock.on("end", (val) => {
|
|
119
|
+
console.log("Connection ended ");
|
|
120
|
+
this.reconnect();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this.sock.on("error", (err) => {
|
|
124
|
+
log4js.debug("connection error " + err);
|
|
125
|
+
requestObj.callback(err, null, null);
|
|
126
|
+
this.reconnect();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
this.sock.on("close", (val) => {
|
|
130
|
+
log4js.debug("connection closed " + val);
|
|
131
|
+
this.reconnect();
|
|
132
|
+
});
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.log({ error });
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
module.exports = Feed;
|
package/src/feed/liveNewsFeed.js
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
const log4js = require("../logger");
|
|
2
|
-
const configData = require("../iniparser");
|
|
3
|
-
const { LIVENEWS_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
-
const {
|
|
5
|
-
validateStreamerCallback,
|
|
6
|
-
} = require("../../validations/feedStreamerValidator");
|
|
7
|
-
|
|
8
|
-
class LiveNewsFeed {
|
|
9
|
-
/**
|
|
10
|
-
* Streamer
|
|
11
|
-
* LiveNewsFeed Class for subsribe or unsubsribe News
|
|
12
|
-
*/
|
|
13
|
-
constructor(feed) {
|
|
14
|
-
this.feed = feed;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* LiveNews Feed RequestBody Schema
|
|
19
|
-
* @function liveNewsRequestBody
|
|
20
|
-
* @returns object
|
|
21
|
-
*/
|
|
22
|
-
requestBody = () => {
|
|
23
|
-
return {
|
|
24
|
-
request: {
|
|
25
|
-
streaming_type: "news",
|
|
26
|
-
formFactor: configData.formFactor,
|
|
27
|
-
appID: configData.ApiIdKey,
|
|
28
|
-
response_format: "json",
|
|
29
|
-
request_type: "",
|
|
30
|
-
},
|
|
31
|
-
echo: {},
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Create LiveNews Request Body
|
|
37
|
-
* Returns liveNewsRequestBody
|
|
38
|
-
* @function createLivenewsRequest
|
|
39
|
-
* @param {boolean} subsribe - true for subsribe and false for unsubsribe
|
|
40
|
-
* @returns object
|
|
41
|
-
*/
|
|
42
|
-
createLivenewsRequest = (subscribe = false) => {
|
|
43
|
-
let body = {};
|
|
44
|
-
try {
|
|
45
|
-
body = this.requestBody();
|
|
46
|
-
if (subscribe) {
|
|
47
|
-
body.request.request_type = "subscribe";
|
|
48
|
-
} else {
|
|
49
|
-
body.request.request_type = "unsubscribe";
|
|
50
|
-
}
|
|
51
|
-
} catch (error) {
|
|
52
|
-
log4js.debug("createLivenewsRequest error - " + error);
|
|
53
|
-
} finally {
|
|
54
|
-
return body;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Subsribe LiveNews
|
|
60
|
-
* To subscribe to the streamer, Create the single instance of this mentioning `callback` method. After successsful subscription, `callback` method will be called whenever packet is available at the streamer.
|
|
61
|
-
* @async
|
|
62
|
-
* @function subscribeLiveNewsFeed
|
|
63
|
-
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
subscribeLiveNewsFeed = async (callback) => {
|
|
67
|
-
try {
|
|
68
|
-
/** Validation Start */
|
|
69
|
-
const validateResponse = validateStreamerCallback(callback);
|
|
70
|
-
|
|
71
|
-
if (validateResponse.error) {
|
|
72
|
-
log4js.debug(
|
|
73
|
-
"subscribeLiveNewsFeed validation error - " +
|
|
74
|
-
validateResponse.error.details
|
|
75
|
-
);
|
|
76
|
-
return Promise.reject(validateResponse.error.details);
|
|
77
|
-
}
|
|
78
|
-
/** Validation End */
|
|
79
|
-
|
|
80
|
-
/** Get LiveNews Request */
|
|
81
|
-
const liveNewsRequest = this.createLivenewsRequest(true);
|
|
82
|
-
/** Call connect method of Feed Class */
|
|
83
|
-
this.feed.subsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest, callback);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
log4js.debug("subscribeLiveNewsFeed error - " + error);
|
|
86
|
-
console.log(error);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Unsubsribe LiveNews Feed
|
|
92
|
-
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
93
|
-
* @async
|
|
94
|
-
* @function unsubscribeLiveNewsFeed
|
|
95
|
-
* @param {Object[]} - Array of unsubsribe Symbols
|
|
96
|
-
* @returns
|
|
97
|
-
*/
|
|
98
|
-
unsubscribeLiveNewsFeed = async () => {
|
|
99
|
-
try {
|
|
100
|
-
/** Get LiveNews Request */
|
|
101
|
-
const liveNewsRequest = this.createLivenewsRequest();
|
|
102
|
-
|
|
103
|
-
/** Unsubscribe liveNews */
|
|
104
|
-
this.feed.unsubsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
log4js.debug("unsubscribeLiveNews error - " + error);
|
|
107
|
-
console.log(error);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
module.exports = LiveNewsFeed;
|
|
1
|
+
const log4js = require("../logger");
|
|
2
|
+
const configData = require("../iniparser");
|
|
3
|
+
const { LIVENEWS_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
+
const {
|
|
5
|
+
validateStreamerCallback,
|
|
6
|
+
} = require("../../validations/feedStreamerValidator");
|
|
7
|
+
|
|
8
|
+
class LiveNewsFeed {
|
|
9
|
+
/**
|
|
10
|
+
* Streamer
|
|
11
|
+
* LiveNewsFeed Class for subsribe or unsubsribe News
|
|
12
|
+
*/
|
|
13
|
+
constructor(feed) {
|
|
14
|
+
this.feed = feed;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* LiveNews Feed RequestBody Schema
|
|
19
|
+
* @function liveNewsRequestBody
|
|
20
|
+
* @returns object
|
|
21
|
+
*/
|
|
22
|
+
requestBody = () => {
|
|
23
|
+
return {
|
|
24
|
+
request: {
|
|
25
|
+
streaming_type: "news",
|
|
26
|
+
formFactor: configData.formFactor,
|
|
27
|
+
appID: configData.ApiIdKey,
|
|
28
|
+
response_format: "json",
|
|
29
|
+
request_type: "",
|
|
30
|
+
},
|
|
31
|
+
echo: {},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create LiveNews Request Body
|
|
37
|
+
* Returns liveNewsRequestBody
|
|
38
|
+
* @function createLivenewsRequest
|
|
39
|
+
* @param {boolean} subsribe - true for subsribe and false for unsubsribe
|
|
40
|
+
* @returns object
|
|
41
|
+
*/
|
|
42
|
+
createLivenewsRequest = (subscribe = false) => {
|
|
43
|
+
let body = {};
|
|
44
|
+
try {
|
|
45
|
+
body = this.requestBody();
|
|
46
|
+
if (subscribe) {
|
|
47
|
+
body.request.request_type = "subscribe";
|
|
48
|
+
} else {
|
|
49
|
+
body.request.request_type = "unsubscribe";
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
log4js.debug("createLivenewsRequest error - " + error);
|
|
53
|
+
} finally {
|
|
54
|
+
return body;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Subsribe LiveNews
|
|
60
|
+
* To subscribe to the streamer, Create the single instance of this mentioning `callback` method. After successsful subscription, `callback` method will be called whenever packet is available at the streamer.
|
|
61
|
+
* @async
|
|
62
|
+
* @function subscribeLiveNewsFeed
|
|
63
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
subscribeLiveNewsFeed = async (callback) => {
|
|
67
|
+
try {
|
|
68
|
+
/** Validation Start */
|
|
69
|
+
const validateResponse = validateStreamerCallback(callback);
|
|
70
|
+
|
|
71
|
+
if (validateResponse.error) {
|
|
72
|
+
log4js.debug(
|
|
73
|
+
"subscribeLiveNewsFeed validation error - " +
|
|
74
|
+
validateResponse.error.details
|
|
75
|
+
);
|
|
76
|
+
return Promise.reject(validateResponse.error.details);
|
|
77
|
+
}
|
|
78
|
+
/** Validation End */
|
|
79
|
+
|
|
80
|
+
/** Get LiveNews Request */
|
|
81
|
+
const liveNewsRequest = this.createLivenewsRequest(true);
|
|
82
|
+
/** Call connect method of Feed Class */
|
|
83
|
+
this.feed.subsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest, callback);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
log4js.debug("subscribeLiveNewsFeed error - " + error);
|
|
86
|
+
console.log(error);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Unsubsribe LiveNews Feed
|
|
92
|
+
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
93
|
+
* @async
|
|
94
|
+
* @function unsubscribeLiveNewsFeed
|
|
95
|
+
* @param {Object[]} - Array of unsubsribe Symbols
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
unsubscribeLiveNewsFeed = async () => {
|
|
99
|
+
try {
|
|
100
|
+
/** Get LiveNews Request */
|
|
101
|
+
const liveNewsRequest = this.createLivenewsRequest();
|
|
102
|
+
|
|
103
|
+
/** Unsubscribe liveNews */
|
|
104
|
+
this.feed.unsubsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
log4js.debug("unsubscribeLiveNews error - " + error);
|
|
107
|
+
console.log(error);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = LiveNewsFeed;
|