@quotemedia.com/streamer 2.31.0 → 2.33.0
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 +2 -2
- package/examples/enduser-example.html +1 -1
- package/examples/enterprise-token-example.html +1 -1
- package/examples/reconnect-example.html +1 -1
- package/examples/subscription-example.html +1 -1
- package/examples/wmid-example.html +1 -1
- package/package.json +1 -1
- package/{qmci-streamer-2.31.0.js → qmci-streamer-2.33.0.js} +329 -38
- package/qmci-streamer-2.33.0.min.js +115 -0
- package/qmci-streamer-2.31.0.min.js +0 -115
|
@@ -37,6 +37,15 @@ var Connection = function () {
|
|
|
37
37
|
//probably means that an unhandled loop was reached
|
|
38
38
|
this.maxReconnectsTotal = 3;
|
|
39
39
|
this.isFirstConnection = true;
|
|
40
|
+
this.atmoCodes = {
|
|
41
|
+
1000: "Normal closure; the connection successfully completed whatever purpose for which it was created.",
|
|
42
|
+
1001: "The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.",
|
|
43
|
+
1002: "The endpoint is terminating the connection due to a protocol error.",
|
|
44
|
+
1003: "The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data).",
|
|
45
|
+
1004: "The endpoint is terminating the connection because a data frame was received that is too large.",
|
|
46
|
+
1005: "Unknown: no status code was provided even though one was expected.",
|
|
47
|
+
1006: "Connection was closed abnormally (that is, with no close frame being sent)."
|
|
48
|
+
};
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
Connection.prototype.open = function open() {
|
|
@@ -136,6 +145,7 @@ var Connection = function () {
|
|
|
136
145
|
onClose: function onClose(response) {
|
|
137
146
|
var code = response.status;
|
|
138
147
|
var reason = response.reason || response.reasonPhrase;
|
|
148
|
+
var atmosphereMessage = response.atmoMessage;
|
|
139
149
|
// For whatever reason, Atmosphere sets to 408 when unsubscribing (e.g., when refreshing the page)
|
|
140
150
|
if (code === 408 && response.state === "unsubscribe") {
|
|
141
151
|
code = 200;
|
|
@@ -143,10 +153,18 @@ var Connection = function () {
|
|
|
143
153
|
}
|
|
144
154
|
//When 501 code is sent it could mean that the server is down, therefore do not continue trying to reconnect
|
|
145
155
|
if (code === 501 || code === 401 || code === 403 || code === 452) {
|
|
146
|
-
_this.log.
|
|
156
|
+
_this.log.warn("Unable to reconnect with code: " + code + ", reason: " + reason);
|
|
147
157
|
_this.reconnect = false;
|
|
148
158
|
}
|
|
149
|
-
|
|
159
|
+
if (atmosphereMessage && atmosphereMessage.code in _this.atmoCodes) {
|
|
160
|
+
_this.log.error("Unexpected close. Code: " + atmosphereMessage.code + " Reason: " + _this.atmoCodes[atmosphereMessage.code]);
|
|
161
|
+
_this.events.fire("atmoError", events.error("Atmosphere error", {
|
|
162
|
+
reason: _this.atmoCodes[atmosphereMessage.code],
|
|
163
|
+
code: atmosphereMessage.code
|
|
164
|
+
}));
|
|
165
|
+
code = 410;
|
|
166
|
+
reason = "Gone";
|
|
167
|
+
}
|
|
150
168
|
var e = events.close({
|
|
151
169
|
url: url,
|
|
152
170
|
transport: response.transport,
|
|
@@ -164,6 +182,8 @@ var Connection = function () {
|
|
|
164
182
|
timesExceeded: response.timesExceeded,
|
|
165
183
|
maxExceeded: response.maxExceed
|
|
166
184
|
});
|
|
185
|
+
_this.reconnect = false;
|
|
186
|
+
_this.log.warn("Slow connection received, Reconnection will not be attempted.");
|
|
167
187
|
_this.log.info(e);
|
|
168
188
|
_this.events.fire("slow", e);
|
|
169
189
|
}
|
|
@@ -198,23 +218,24 @@ var Connection = function () {
|
|
|
198
218
|
}
|
|
199
219
|
this.isFirstConnection = false;
|
|
200
220
|
var currentAttempts = this.maxReconnectAttempts;
|
|
201
|
-
|
|
221
|
+
// Recursively run this until a successful open is completed
|
|
222
|
+
var reconnect = function reconnect() {
|
|
202
223
|
if (currentAttempts <= 0) {
|
|
203
224
|
_this2.reconnect = false;
|
|
204
225
|
_this2.log.error("Error while reconnecting. No attempts left.");
|
|
205
226
|
//if maxattempts was reached and no connection was open, exit.
|
|
206
227
|
_this2.maxReconnectAttempts = 0;
|
|
207
|
-
clearInterval(reopenInterval);
|
|
208
228
|
return;
|
|
209
229
|
}
|
|
210
230
|
if (_this2.isConnectionUp || !_this2.reconnect) {
|
|
211
|
-
clearInterval(reopenInterval);
|
|
212
231
|
return;
|
|
213
232
|
}
|
|
214
233
|
_this2.log.info("Attempting reconnect. Attempts left: " + currentAttempts);
|
|
215
234
|
_this2.reopen(currentAttempts);
|
|
216
235
|
currentAttempts--;
|
|
217
|
-
|
|
236
|
+
setTimeout(reconnect, 500);
|
|
237
|
+
};
|
|
238
|
+
setTimeout(reconnect, 500);
|
|
218
239
|
};
|
|
219
240
|
|
|
220
241
|
Connection.prototype.reopen = function reopen(attempt) {
|
|
@@ -254,10 +275,6 @@ var Connection = function () {
|
|
|
254
275
|
return this.socket == null;
|
|
255
276
|
};
|
|
256
277
|
|
|
257
|
-
Connection.prototype.getConnectionUp = function getConnectionUp() {
|
|
258
|
-
return this.isConnectionUp;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
278
|
Connection.prototype.on = function on(event, callback) {
|
|
262
279
|
return this.events.on(event, callback);
|
|
263
280
|
};
|
|
@@ -536,6 +553,8 @@ var Stream = function () {
|
|
|
536
553
|
_this.events.fire("error", err);
|
|
537
554
|
}).on("reconnect", function (msg) {
|
|
538
555
|
_this.reconnectSuccess(msg);
|
|
556
|
+
}).on("atmoError", function (err) {
|
|
557
|
+
_this.events.fire("atmoError", err);
|
|
539
558
|
});
|
|
540
559
|
|
|
541
560
|
this.requestid = new _UShortId2["default"]();
|
|
@@ -1647,13 +1666,10 @@ var Stream = function () {
|
|
|
1647
1666
|
};
|
|
1648
1667
|
|
|
1649
1668
|
Stream.prototype.onReconnectMessage = function onReconnectMessage(msg) {
|
|
1650
|
-
if (msg.code
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
});
|
|
1655
|
-
this.events.fire("error", event);
|
|
1656
|
-
this.doClose(event);
|
|
1669
|
+
if (msg.code === 450) {
|
|
1670
|
+
this.events.fire("slow", "Reconnection recieved a slow code: " + msg.code);
|
|
1671
|
+
this._isSlowConnection = true;
|
|
1672
|
+
this.conn.setReconnect = false;
|
|
1657
1673
|
}
|
|
1658
1674
|
this.events.fire("reconnectMessage", msg);
|
|
1659
1675
|
console.log(msg);
|
|
@@ -1760,7 +1776,7 @@ var Stream = function () {
|
|
|
1760
1776
|
|
|
1761
1777
|
Stream.prototype.performReconnect = function performReconnect(callback) {
|
|
1762
1778
|
if (this.conn != null && this.conn.isReconnect()) {
|
|
1763
|
-
if (this.conn.
|
|
1779
|
+
if (this.conn.isConnectionUp) {
|
|
1764
1780
|
this.log.warn("Connection is not closed and won't try reconnect.");
|
|
1765
1781
|
return;
|
|
1766
1782
|
}
|
|
@@ -2042,6 +2058,11 @@ var StreamingService = function () {
|
|
|
2042
2058
|
headers['X-Stream-isReceiveLatestMissedData'] = true;
|
|
2043
2059
|
}
|
|
2044
2060
|
|
|
2061
|
+
var _connectionFrom = this.config.connectionFrom;
|
|
2062
|
+
if (_connectionFrom != null) {
|
|
2063
|
+
headers['X-Stream-connectionFrom'] = _connectionFrom;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2045
2066
|
Object.assign(headers, this.config.credentials.getHeaders());
|
|
2046
2067
|
|
|
2047
2068
|
var request = {
|
|
@@ -3675,7 +3696,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
3675
3696
|
return;
|
|
3676
3697
|
}
|
|
3677
3698
|
|
|
3678
|
-
|
|
3699
|
+
//Patched by Quotemedia
|
|
3700
|
+
_invokeClose(webSocketOpened, message);
|
|
3679
3701
|
|
|
3680
3702
|
_response.state = 'closed';
|
|
3681
3703
|
|
|
@@ -4998,11 +5020,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
4998
5020
|
}
|
|
4999
5021
|
}
|
|
5000
5022
|
|
|
5001
|
-
|
|
5023
|
+
//Patched by Quotemedia
|
|
5024
|
+
function _invokeClose(wasOpen, message) {
|
|
5002
5025
|
if (_response.state !== 'closed') {
|
|
5003
5026
|
_response.state = 'closed';
|
|
5004
5027
|
_response.responseBody = "";
|
|
5005
5028
|
_response.messages = [];
|
|
5029
|
+
_response.atmoMessage = message;
|
|
5006
5030
|
_response.status = !wasOpen ? 501 : 200;
|
|
5007
5031
|
_invokeCallback();
|
|
5008
5032
|
}
|
|
@@ -5920,6 +5944,7 @@ fmt.Formatter = function () {
|
|
|
5920
5944
|
this.formatters[_streamerApi.messages.MessageTypeNames.data.TRADENOTIFICATION] = this._fmttradeNotification;
|
|
5921
5945
|
this.formatters[_streamerApi.messages.MessageTypeNames.data.NEWSCMDFILTER] = this._fmtnewscmdfilter;
|
|
5922
5946
|
this.formatters[_streamerApi.messages.MessageTypeNames.data.NEWSERROR] = this._fmtnewserror;
|
|
5947
|
+
this.formatters[_streamerApi.messages.MessageTypeNames.data.DIVIDEND] = this._fmtdividend;
|
|
5923
5948
|
};
|
|
5924
5949
|
|
|
5925
5950
|
fmt.Formatter._UNKOWNTYPE = '__UNKNOWN__';
|
|
@@ -6554,6 +6579,33 @@ fmt.Formatter.prototype._fmtnewserror = function (val) {
|
|
|
6554
6579
|
return s.toString();
|
|
6555
6580
|
};
|
|
6556
6581
|
|
|
6582
|
+
fmt.Formatter.prototype._fmtdividend = function (val) {
|
|
6583
|
+
var s = new fmt.StringBuilder();
|
|
6584
|
+
s.append("DV");
|
|
6585
|
+
s.sep();
|
|
6586
|
+
s.datetime(val.occuredOn);
|
|
6587
|
+
s.sep();
|
|
6588
|
+
s.append(val.symbolId);
|
|
6589
|
+
s.sep();
|
|
6590
|
+
s.append(val.instrument);
|
|
6591
|
+
s.sep();
|
|
6592
|
+
s.datetime(val.declarationDate);
|
|
6593
|
+
s.sep();
|
|
6594
|
+
s.datetime(val.executionDate);
|
|
6595
|
+
s.sep();
|
|
6596
|
+
s.datetime(val.recordDate);
|
|
6597
|
+
s.sep();
|
|
6598
|
+
s.datetime(val.paymentDate);
|
|
6599
|
+
s.sep();
|
|
6600
|
+
s.append(val.amount);
|
|
6601
|
+
s.sep();
|
|
6602
|
+
s.append(val.frequency);
|
|
6603
|
+
s.sep();
|
|
6604
|
+
s.append(val.paymentType);
|
|
6605
|
+
|
|
6606
|
+
return s.toString();
|
|
6607
|
+
};
|
|
6608
|
+
|
|
6557
6609
|
fmt.Formatter.prototype._fmtheartbeat = function (val) {
|
|
6558
6610
|
var s = new fmt.StringBuilder();
|
|
6559
6611
|
s.append("HEARBEAT");
|
|
@@ -6733,6 +6785,8 @@ fmt.Formatter.prototype._fmtreconnectresponse = function (val) {
|
|
|
6733
6785
|
s.append(val.maxEntitlementsPerSubscription);
|
|
6734
6786
|
s.sep();
|
|
6735
6787
|
s.sep(val.entitlements);
|
|
6788
|
+
s.sep();
|
|
6789
|
+
s.sep(val.exchangeEntitlements);
|
|
6736
6790
|
return s.toString();
|
|
6737
6791
|
};
|
|
6738
6792
|
|
|
@@ -6832,6 +6886,10 @@ fmt.Formatter.prototype._fmtmisseddatasent = function (val) {
|
|
|
6832
6886
|
s.datetime(val.timestamp);
|
|
6833
6887
|
s.sep();
|
|
6834
6888
|
s.append(val.requestId);
|
|
6889
|
+
s.sep();
|
|
6890
|
+
s.append(val.totalDataSent);
|
|
6891
|
+
s.sep();
|
|
6892
|
+
s.append(val.totalDataHeld);
|
|
6835
6893
|
return s.toString();
|
|
6836
6894
|
};
|
|
6837
6895
|
|
|
@@ -12470,6 +12528,10 @@ var _streamerEvents = require("../streamer-events.js");
|
|
|
12470
12528
|
|
|
12471
12529
|
var events = _interopRequireWildcard(_streamerEvents);
|
|
12472
12530
|
|
|
12531
|
+
var _http = require("../http.js");
|
|
12532
|
+
|
|
12533
|
+
var _http2 = _interopRequireDefault(_http);
|
|
12534
|
+
|
|
12473
12535
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
|
|
12474
12536
|
|
|
12475
12537
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -12478,12 +12540,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
12478
12540
|
|
|
12479
12541
|
var StompConnection = function () {
|
|
12480
12542
|
function StompConnection(createTransmitter, openSocket, log) {
|
|
12543
|
+
var maxReconnectAttempts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 3;
|
|
12544
|
+
var pingUrl = arguments[4];
|
|
12545
|
+
|
|
12481
12546
|
_classCallCheck(this, StompConnection);
|
|
12482
12547
|
|
|
12483
12548
|
this.openSocket = openSocket;
|
|
12484
12549
|
this.createTransmitter = createTransmitter;
|
|
12485
12550
|
this.log = (0, _logging.asLogger)(log);
|
|
12486
12551
|
this.events = new _EventSupport2["default"](this);
|
|
12552
|
+
this.currentConn = '';
|
|
12553
|
+
//Max number of times that the client will try to reopen per loop
|
|
12554
|
+
this.maxReconnectAttempts = maxReconnectAttempts;
|
|
12555
|
+
//Max number of times client will be able to try to reopen in total. Once this is reached, client will close and no reconnect will be attempted.
|
|
12556
|
+
//probably means that an unhandled loop was reached
|
|
12557
|
+
this.maxReconnectsTotal = 3;
|
|
12558
|
+
this.isFirstConnection = true;
|
|
12559
|
+
this.pingUrl = pingUrl;
|
|
12487
12560
|
}
|
|
12488
12561
|
|
|
12489
12562
|
StompConnection.prototype.open = function open() {
|
|
@@ -12495,21 +12568,70 @@ var StompConnection = function () {
|
|
|
12495
12568
|
}
|
|
12496
12569
|
};
|
|
12497
12570
|
|
|
12498
|
-
|
|
12571
|
+
//Check to avoid creating unnecessary events and objects
|
|
12572
|
+
if (this.isFirstConnection) {
|
|
12573
|
+
this.on("reopen", function (e) {
|
|
12574
|
+
var prevConn = _this.currentConn;
|
|
12575
|
+
_this.currentConn = e.connectionId;
|
|
12576
|
+
_this.events.fire("reconnect", events.event("Reconnection success", {
|
|
12577
|
+
previousConnectionId: prevConn,
|
|
12578
|
+
currentConnectionId: _this.currentConn
|
|
12579
|
+
}));
|
|
12580
|
+
});
|
|
12499
12581
|
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12582
|
+
this.transmitter = this.createTransmitter(socketProxy);
|
|
12583
|
+
this.transmitter.on("message", function (message) {
|
|
12584
|
+
_this.events.fire("message", message);
|
|
12585
|
+
});
|
|
12586
|
+
}
|
|
12503
12587
|
|
|
12504
12588
|
this.socket = this.openSocket(function (request) {
|
|
12505
12589
|
_this.request = request;
|
|
12590
|
+
_this.reconnect = false;
|
|
12506
12591
|
return {
|
|
12592
|
+
onOpen: function onOpen(response) {
|
|
12593
|
+
if (response.command === "CONNECTED") {
|
|
12594
|
+
_this.isConnectionUp = true;
|
|
12595
|
+
var e = events.event("open", {
|
|
12596
|
+
connectionId: response.headers['user-name']
|
|
12597
|
+
});
|
|
12598
|
+
_this.log.info(e);
|
|
12599
|
+
_this.events.fire("open", e);
|
|
12600
|
+
if (!_this.isFirstConnection) {
|
|
12601
|
+
_this.maxReconnectsTotal--;
|
|
12602
|
+
_this.events.fire("reopen", e);
|
|
12603
|
+
}
|
|
12604
|
+
_this.currentConn = response.headers['user-name'];
|
|
12605
|
+
}
|
|
12606
|
+
},
|
|
12607
|
+
onError: function onError(response) {
|
|
12608
|
+
_this.isConnectionUp = false;
|
|
12609
|
+
_this.isServerUp(function (err, result) {
|
|
12610
|
+
if (err !== null) {
|
|
12611
|
+
_this.reconnect = false;
|
|
12612
|
+
_this.log.warn("Connection lost, Streamer Server isn't Up");
|
|
12613
|
+
} else {
|
|
12614
|
+
_this.reconnect = true;
|
|
12615
|
+
_this.log.warn('Connection lost, Streamer Server is Up');
|
|
12616
|
+
}
|
|
12617
|
+
});
|
|
12618
|
+
},
|
|
12619
|
+
onClose: function onClose() {
|
|
12620
|
+
_this.isConnectionUp = false;
|
|
12621
|
+
},
|
|
12507
12622
|
onMessage: function onMessage(response) {
|
|
12623
|
+
var responseBody = JSON.parse(response.body);
|
|
12624
|
+
if (responseBody.code !== undefined) {
|
|
12625
|
+
if (responseBody.code == 401 || responseBody.code == 403) {
|
|
12626
|
+
_this.log.info("Unable to reconnect with code: " + responseBody.code + ", reason: " + responseBody.reason);
|
|
12627
|
+
_this.reconnect = false;
|
|
12628
|
+
_this.isConnectionUp = false;
|
|
12629
|
+
}
|
|
12630
|
+
}
|
|
12508
12631
|
_this.transmitter.onMessage(response.body);
|
|
12509
12632
|
}
|
|
12510
|
-
|
|
12511
12633
|
};
|
|
12512
|
-
});
|
|
12634
|
+
}, this.currentConn);
|
|
12513
12635
|
};
|
|
12514
12636
|
|
|
12515
12637
|
StompConnection.prototype.close = function close() {
|
|
@@ -12517,6 +12639,9 @@ var StompConnection = function () {
|
|
|
12517
12639
|
try {
|
|
12518
12640
|
this.socket.close();
|
|
12519
12641
|
this.socket = null;
|
|
12642
|
+
if (this.reconnect) {
|
|
12643
|
+
this.tryReopen();
|
|
12644
|
+
}
|
|
12520
12645
|
} catch (err) {
|
|
12521
12646
|
this.events.fire("error", events.error("Error closing", {
|
|
12522
12647
|
reason: err.message,
|
|
@@ -12527,6 +12652,44 @@ var StompConnection = function () {
|
|
|
12527
12652
|
}
|
|
12528
12653
|
};
|
|
12529
12654
|
|
|
12655
|
+
StompConnection.prototype.tryReopen = function tryReopen() {
|
|
12656
|
+
var _this2 = this;
|
|
12657
|
+
|
|
12658
|
+
if (this.isConnectionUp || this.maxReconnectsTotal <= 0) {
|
|
12659
|
+
this.log.error("Connection is already open or max reconnects was reached, won't try to reconnect");
|
|
12660
|
+
return;
|
|
12661
|
+
}
|
|
12662
|
+
this.isFirstConnection = false;
|
|
12663
|
+
var currentAttempts = this.maxReconnectAttempts;
|
|
12664
|
+
var reconnect = function reconnect() {
|
|
12665
|
+
if (currentAttempts <= 0) {
|
|
12666
|
+
_this2.reconnect = false;
|
|
12667
|
+
_this2.log.error("Error while reconnecting. No attempts left.");
|
|
12668
|
+
//if maxattempts was reached and no connection was open, exit.
|
|
12669
|
+
_this2.maxReconnectAttempts = 0;
|
|
12670
|
+
return;
|
|
12671
|
+
}
|
|
12672
|
+
if (_this2.isConnectionUp || !_this2.reconnect) {
|
|
12673
|
+
return;
|
|
12674
|
+
}
|
|
12675
|
+
_this2.log.info("Attempting reconnect. Attempts left: " + currentAttempts);
|
|
12676
|
+
_this2.reopen(currentAttempts);
|
|
12677
|
+
currentAttempts--;
|
|
12678
|
+
|
|
12679
|
+
setTimeout(reconnect, 500);
|
|
12680
|
+
};
|
|
12681
|
+
setTimeout(reconnect, 500);
|
|
12682
|
+
};
|
|
12683
|
+
|
|
12684
|
+
StompConnection.prototype.reopen = function reopen(attempt) {
|
|
12685
|
+
try {
|
|
12686
|
+
this.open();
|
|
12687
|
+
} catch (exception) {
|
|
12688
|
+
this.log.warn("There was an error while reopening attempt #" + attempt);
|
|
12689
|
+
this.events.fire("error", exception);
|
|
12690
|
+
}
|
|
12691
|
+
};
|
|
12692
|
+
|
|
12530
12693
|
StompConnection.prototype.send = function send(message) {
|
|
12531
12694
|
try {
|
|
12532
12695
|
this.transmitter.send(message);
|
|
@@ -12539,6 +12702,14 @@ var StompConnection = function () {
|
|
|
12539
12702
|
}
|
|
12540
12703
|
};
|
|
12541
12704
|
|
|
12705
|
+
StompConnection.prototype.isReconnect = function isReconnect() {
|
|
12706
|
+
return this.request['x-Stream-isReconnect'];
|
|
12707
|
+
};
|
|
12708
|
+
|
|
12709
|
+
StompConnection.prototype.setReconnect = function setReconnect(doReconnect) {
|
|
12710
|
+
this.reconnect = doReconnect;
|
|
12711
|
+
};
|
|
12712
|
+
|
|
12542
12713
|
StompConnection.prototype.setServer = function setServer(server) {
|
|
12543
12714
|
this.request['X-Stream-Instance'] = server;
|
|
12544
12715
|
};
|
|
@@ -12547,6 +12718,21 @@ var StompConnection = function () {
|
|
|
12547
12718
|
return this.socket == null;
|
|
12548
12719
|
};
|
|
12549
12720
|
|
|
12721
|
+
StompConnection.prototype.isServerUp = function isServerUp(callback) {
|
|
12722
|
+
(0, _http2["default"])({
|
|
12723
|
+
url: this.pingUrl,
|
|
12724
|
+
success: function success(result) {
|
|
12725
|
+
return callback(null, result);
|
|
12726
|
+
},
|
|
12727
|
+
type: "GET",
|
|
12728
|
+
failure: callback
|
|
12729
|
+
});
|
|
12730
|
+
};
|
|
12731
|
+
|
|
12732
|
+
StompConnection.prototype.setConnectionUp = function setConnectionUp(isConnectionUp) {
|
|
12733
|
+
this.isConnectionUp = isConnectionUp;
|
|
12734
|
+
};
|
|
12735
|
+
|
|
12550
12736
|
StompConnection.prototype.on = function on(event, callback) {
|
|
12551
12737
|
return this.events.on(event, callback);
|
|
12552
12738
|
};
|
|
@@ -12556,7 +12742,7 @@ var StompConnection = function () {
|
|
|
12556
12742
|
|
|
12557
12743
|
exports["default"] = StompConnection;
|
|
12558
12744
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],require("timers").setImmediate,require("timers").clearImmediate,"/lib/stomp/StompConnection.js","/lib/stomp")
|
|
12559
|
-
},{"../EventSupport.js":2,"../logging.js":16,"../streamer-events.js":97,"_process":119,"buffer":109,"timers":140}],94:[function(require,module,exports){
|
|
12745
|
+
},{"../EventSupport.js":2,"../http.js":14,"../logging.js":16,"../streamer-events.js":97,"_process":119,"buffer":109,"timers":140}],94:[function(require,module,exports){
|
|
12560
12746
|
(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,setImmediate,clearImmediate,__filename,__dirname){
|
|
12561
12747
|
"use strict";
|
|
12562
12748
|
|
|
@@ -12617,6 +12803,8 @@ var StompStream = function () {
|
|
|
12617
12803
|
_this.pendingConnection(err);
|
|
12618
12804
|
}
|
|
12619
12805
|
_this.events.fire("error", err);
|
|
12806
|
+
}).on("reconnect", function (msg) {
|
|
12807
|
+
_this.reconnectSuccess(msg);
|
|
12620
12808
|
});
|
|
12621
12809
|
|
|
12622
12810
|
this.requestid = new _UShortId2["default"]();
|
|
@@ -12647,6 +12835,11 @@ var StompStream = function () {
|
|
|
12647
12835
|
}
|
|
12648
12836
|
};
|
|
12649
12837
|
|
|
12838
|
+
StompStream.prototype.reconnectSuccess = function reconnectSuccess(msg) {
|
|
12839
|
+
this.events.fire("reconnectSuccess", msg);
|
|
12840
|
+
this.log.info("Successfull reconnection. Previous Id: " + msg.previousConnectionId + " Current Id = " + msg.currentConnectionId);
|
|
12841
|
+
};
|
|
12842
|
+
|
|
12650
12843
|
StompStream.prototype.on = function on(event, listener) {
|
|
12651
12844
|
return this.events.on(event, listener);
|
|
12652
12845
|
};
|
|
@@ -13260,6 +13453,12 @@ var StompStream = function () {
|
|
|
13260
13453
|
case _streamerApi.messages.MessageTypeNames.ctrl.OPEN_FLOW:
|
|
13261
13454
|
this.onOpenFlow(msg);
|
|
13262
13455
|
break;
|
|
13456
|
+
case _streamerApi.messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE:
|
|
13457
|
+
this.onReconnectMessage(msg);
|
|
13458
|
+
break;
|
|
13459
|
+
case _streamerApi.messages.MessageTypeNames.ctrl.MISSED_DATA_SENT:
|
|
13460
|
+
this.onMissedDataSent(msg);
|
|
13461
|
+
break;
|
|
13263
13462
|
}
|
|
13264
13463
|
};
|
|
13265
13464
|
|
|
@@ -13719,8 +13918,18 @@ var StompStream = function () {
|
|
|
13719
13918
|
}
|
|
13720
13919
|
};
|
|
13721
13920
|
|
|
13921
|
+
StompStream.prototype.onReconnectMessage = function onReconnectMessage(msg) {
|
|
13922
|
+
if (msg.code === 450) {
|
|
13923
|
+
this.events.fire("slow", "Reconnection recieved a slow code: " + msg.code);
|
|
13924
|
+
this._isSlowConnection = true;
|
|
13925
|
+
this.conn.setReconnect = false;
|
|
13926
|
+
}
|
|
13927
|
+
this.events.fire("reconnectMessage", msg);
|
|
13928
|
+
console.log(msg);
|
|
13929
|
+
};
|
|
13930
|
+
|
|
13722
13931
|
StompStream.prototype.onConnectResponse = function onConnectResponse(msg) {
|
|
13723
|
-
if (msg.code
|
|
13932
|
+
if (msg.code !== 200) {
|
|
13724
13933
|
var event = events.error("Connection failed", {
|
|
13725
13934
|
code: msg.code,
|
|
13726
13935
|
reason: msg.reason
|
|
@@ -13787,6 +13996,11 @@ var StompStream = function () {
|
|
|
13787
13996
|
this.events.fire("resubscribeMessage", msg);
|
|
13788
13997
|
};
|
|
13789
13998
|
|
|
13999
|
+
StompStream.prototype.onMissedDataSent = function onMissedDataSent(msg) {
|
|
14000
|
+
this.log.debug(_formatting.msgfmt.fmt(msg));
|
|
14001
|
+
this.events.fire("missedDataSent", msg);
|
|
14002
|
+
};
|
|
14003
|
+
|
|
13790
14004
|
StompStream.prototype.onOpenFlow = function onOpenFlow(msg) {
|
|
13791
14005
|
this.conn.send(msg);
|
|
13792
14006
|
};
|
|
@@ -13805,8 +14019,29 @@ var StompStream = function () {
|
|
|
13805
14019
|
if (!this.isClosed()) {
|
|
13806
14020
|
var conn = this.conn;
|
|
13807
14021
|
this.conn = null;
|
|
13808
|
-
this.events.fire("close", msg);
|
|
13809
14022
|
conn.close();
|
|
14023
|
+
this.events.fire("close", msg);
|
|
14024
|
+
if (conn.isReconnect()) {
|
|
14025
|
+
//Will need to reset the events since they duplicate each time it reconnects.
|
|
14026
|
+
this.events = new _EventSupport2["default"]();
|
|
14027
|
+
this.conn = conn;
|
|
14028
|
+
}
|
|
14029
|
+
}
|
|
14030
|
+
};
|
|
14031
|
+
|
|
14032
|
+
StompStream.prototype.performReconnect = function performReconnect(callback) {
|
|
14033
|
+
if (this.conn != null && this.conn.isReconnect()) {
|
|
14034
|
+
if (this.conn.isConnectionUp) {
|
|
14035
|
+
this.log.warn("Connection is not closed and won't try reconnect.");
|
|
14036
|
+
return;
|
|
14037
|
+
}
|
|
14038
|
+
this.conn.setReconnect(true);
|
|
14039
|
+
this.conn.tryReopen();
|
|
14040
|
+
if (callback) {
|
|
14041
|
+
callback();
|
|
14042
|
+
}
|
|
14043
|
+
} else {
|
|
14044
|
+
this.log.warn("Reconnect flag is set to false");
|
|
13810
14045
|
}
|
|
13811
14046
|
};
|
|
13812
14047
|
|
|
@@ -13865,6 +14100,8 @@ var STREAMURLS = {
|
|
|
13865
14100
|
"streamStomp": "/stream/connect"
|
|
13866
14101
|
};
|
|
13867
14102
|
|
|
14103
|
+
var HEADERPARAMS = '';
|
|
14104
|
+
|
|
13868
14105
|
var StompStreamingService = function () {
|
|
13869
14106
|
function StompStreamingService(http, stompJs, log, config) {
|
|
13870
14107
|
var _this = this;
|
|
@@ -13875,6 +14112,7 @@ var StompStreamingService = function () {
|
|
|
13875
14112
|
this.stompJs = stompJs;
|
|
13876
14113
|
this.log = (0, _logging.asLogger)(log);
|
|
13877
14114
|
this.config = config || {};
|
|
14115
|
+
this.maxReconnectAttempts = this.config.maxReconnectAttempts;
|
|
13878
14116
|
|
|
13879
14117
|
this.format = this.config.format;
|
|
13880
14118
|
if (this.config.format === 'application/json') {
|
|
@@ -13884,33 +14122,65 @@ var StompStreamingService = function () {
|
|
|
13884
14122
|
}
|
|
13885
14123
|
}
|
|
13886
14124
|
|
|
13887
|
-
StompStreamingService.prototype.openStompSocket = function openStompSocket(handlers) {
|
|
14125
|
+
StompStreamingService.prototype.openStompSocket = function openStompSocket(handlers, connectionId) {
|
|
14126
|
+
HEADERPARAMS = '';
|
|
13888
14127
|
var headers = {
|
|
13889
14128
|
'X-Stream-Version': _streamerApi.VERSION,
|
|
13890
14129
|
'X-Stream-Lib': _streamerApi.LIBRARY_NAME
|
|
13891
14130
|
};
|
|
14131
|
+
this.addToHeaderParams('X-Stream-Version', _streamerApi.VERSION);
|
|
14132
|
+
this.addToHeaderParams('X-Stream-Lib', _streamerApi.LIBRARY_NAME);
|
|
13892
14133
|
|
|
13893
14134
|
var _conflation = this.config.conflation;
|
|
13894
14135
|
if (_conflation != null && _conflation !== '') {
|
|
13895
14136
|
headers['X-Stream-Conflation'] = _conflation;
|
|
14137
|
+
this.addToHeaderParams('X-Stream-Conflation', _conflation);
|
|
14138
|
+
}
|
|
14139
|
+
|
|
14140
|
+
if (connectionId != null && connectionId !== '') {
|
|
14141
|
+
headers['X-Stream-Previous-Connection-Id'] = connectionId;
|
|
14142
|
+
this.addToHeaderParams('X-Stream-Previous-Connection-Id', connectionId);
|
|
13896
14143
|
}
|
|
13897
14144
|
|
|
13898
14145
|
var _rejectExcessiveConnection = this.config.rejectExcessiveConnection;
|
|
13899
14146
|
if (_rejectExcessiveConnection != null && _rejectExcessiveConnection !== '') {
|
|
13900
14147
|
headers['X-Stream-Reject'] = _rejectExcessiveConnection;
|
|
14148
|
+
this.addToHeaderParams('X-Stream-Reject', _rejectExcessiveConnection);
|
|
13901
14149
|
}
|
|
13902
14150
|
|
|
13903
14151
|
if (this.config.format === 'application/json' || this.config.format === _message.MimeTypes.QITCH) {
|
|
13904
14152
|
headers['X-Stream-Format'] = this.format;
|
|
14153
|
+
this.addToHeaderParams('X-Stream-Format', this.format);
|
|
13905
14154
|
}
|
|
13906
14155
|
|
|
13907
14156
|
if (this.config.updatesOnly === 'true') {
|
|
13908
14157
|
headers['X-Stream-UpdatesOnly'] = true;
|
|
14158
|
+
this.addToHeaderParams('X-Stream-UpdatesOnly', true);
|
|
14159
|
+
}
|
|
14160
|
+
|
|
14161
|
+
var _isReconnect = this.config.isReconnect;
|
|
14162
|
+
if (_isReconnect != null && _isReconnect !== '') {
|
|
14163
|
+
headers['x-Stream-isReconnect'] = _isReconnect;
|
|
14164
|
+
this.addToHeaderParams('x-Stream-isReconnect', _isReconnect);
|
|
14165
|
+
}
|
|
14166
|
+
|
|
14167
|
+
var _alwaysReconnect = this.config.alwaysReconnect;
|
|
14168
|
+
if (_alwaysReconnect != null && _alwaysReconnect !== '') {
|
|
14169
|
+
headers['x-Stream-isAlwaysReopen'] = _alwaysReconnect;
|
|
14170
|
+
this.addToHeaderParams('x-Stream-isAlwaysReopen', _alwaysReconnect);
|
|
14171
|
+
}
|
|
14172
|
+
|
|
14173
|
+
if (this.config.isMissedData === 'ALL') {
|
|
14174
|
+
headers['X-Stream-isReceiveAllMissedData'] = true;
|
|
14175
|
+
this.addToHeaderParams('X-Stream-isReceiveAllMissedData', true);
|
|
14176
|
+
} else if (this.config.isMissedData === 'LATEST') {
|
|
14177
|
+
headers['X-Stream-isReceiveLatestMissedData'] = true;
|
|
14178
|
+
this.addToHeaderParams('X-Stream-isReceiveLatestMissedData', true);
|
|
13909
14179
|
}
|
|
13910
14180
|
|
|
13911
14181
|
Object.assign(headers, this.config.credentials.getHeaders());
|
|
13912
14182
|
|
|
13913
|
-
var url = this.config.url + STREAMURLS.streamStomp;
|
|
14183
|
+
var url = this.config.url + STREAMURLS.streamStomp + HEADERPARAMS;
|
|
13914
14184
|
var stompClient = this.stompJs.Stomp.client(url);
|
|
13915
14185
|
|
|
13916
14186
|
var authMessage = new _streamerApi.messages.control.AuthenticationMessage();
|
|
@@ -13919,6 +14189,7 @@ var StompStreamingService = function () {
|
|
|
13919
14189
|
authMessage.authorization = this.config.credentials.sid;
|
|
13920
14190
|
} else if (this.config.credentials.wmid !== undefined && this.config.credentials.token !== undefined) {
|
|
13921
14191
|
authMessage.authenticationMethod = "enterprise";
|
|
14192
|
+
authMessage.wmid = this.config.credentials.wmid;
|
|
13922
14193
|
authMessage.authorization = this.config.credentials.token;
|
|
13923
14194
|
} else if (this.config.credentials.wmid !== undefined) {
|
|
13924
14195
|
authMessage.authenticationMethod = "wmid";
|
|
@@ -13936,12 +14207,15 @@ var StompStreamingService = function () {
|
|
|
13936
14207
|
authMessage.rejectExcessiveConnection = this.config.rejectExcessiveConnection;
|
|
13937
14208
|
}
|
|
13938
14209
|
|
|
13939
|
-
stompClient.connect(
|
|
14210
|
+
stompClient.connect(headers, function (frame) {
|
|
13940
14211
|
stompClient.subscribe('/user/queue/messages', function (responseMessage) {
|
|
13941
14212
|
handlers(headers).onMessage(responseMessage);
|
|
13942
14213
|
});
|
|
13943
14214
|
|
|
14215
|
+
handlers(headers).onOpen(frame);
|
|
13944
14216
|
stompClient.send("/stream/message", headers, JSON.stringify(authMessage));
|
|
14217
|
+
}, function (frame) {
|
|
14218
|
+
handlers(headers).onError(frame);
|
|
13945
14219
|
});
|
|
13946
14220
|
|
|
13947
14221
|
return {
|
|
@@ -13949,7 +14223,9 @@ var StompStreamingService = function () {
|
|
|
13949
14223
|
stompClient.send("/stream/message", headers, msg);
|
|
13950
14224
|
},
|
|
13951
14225
|
close: function close() {
|
|
13952
|
-
stompClient.disconnect()
|
|
14226
|
+
stompClient.disconnect(function () {
|
|
14227
|
+
handlers(headers).onClose();
|
|
14228
|
+
});
|
|
13953
14229
|
}
|
|
13954
14230
|
};
|
|
13955
14231
|
};
|
|
@@ -13959,9 +14235,9 @@ var StompStreamingService = function () {
|
|
|
13959
14235
|
|
|
13960
14236
|
return new _StompConnection2["default"](function (socket) {
|
|
13961
14237
|
return _this2.createTransmitter(socket);
|
|
13962
|
-
}, function (handlers) {
|
|
13963
|
-
return _this2.openStompSocket(handlers);
|
|
13964
|
-
}, this.
|
|
14238
|
+
}, function (handlers, connectionId) {
|
|
14239
|
+
return _this2.openStompSocket(handlers, connectionId);
|
|
14240
|
+
}, this.log, this.maxReconnectAttempts, this.config.host + STREAMURLS.ping);
|
|
13965
14241
|
};
|
|
13966
14242
|
|
|
13967
14243
|
StompStreamingService.prototype.openStompStream = function openStompStream(callback) {
|
|
@@ -13991,6 +14267,14 @@ var StompStreamingService = function () {
|
|
|
13991
14267
|
});
|
|
13992
14268
|
};
|
|
13993
14269
|
|
|
14270
|
+
StompStreamingService.prototype.addToHeaderParams = function addToHeaderParams(header, val) {
|
|
14271
|
+
if (HEADERPARAMS === '') {
|
|
14272
|
+
HEADERPARAMS = HEADERPARAMS + '?' + header + '=' + val;
|
|
14273
|
+
} else {
|
|
14274
|
+
HEADERPARAMS = HEADERPARAMS + '&' + header + '=' + val;
|
|
14275
|
+
}
|
|
14276
|
+
};
|
|
14277
|
+
|
|
13994
14278
|
return StompStreamingService;
|
|
13995
14279
|
}();
|
|
13996
14280
|
|
|
@@ -14009,7 +14293,7 @@ exports.__esModule = true;
|
|
|
14009
14293
|
*/
|
|
14010
14294
|
|
|
14011
14295
|
var LIBRARY_NAME = exports.LIBRARY_NAME = "JavaScript";
|
|
14012
|
-
var VERSION = exports.VERSION = "2.
|
|
14296
|
+
var VERSION = exports.VERSION = "2.33.0";
|
|
14013
14297
|
|
|
14014
14298
|
/**
|
|
14015
14299
|
* Streamer message api namespace.
|
|
@@ -14104,7 +14388,8 @@ messages.MessageTypeNames = {
|
|
|
14104
14388
|
NEWS: 'D18',
|
|
14105
14389
|
TRADENOTIFICATION: 'D19',
|
|
14106
14390
|
NEWSCMDFILTER: 'D20',
|
|
14107
|
-
NEWSERROR: 'D21'
|
|
14391
|
+
NEWSERROR: 'D21',
|
|
14392
|
+
DIVIDEND: 'D22'
|
|
14108
14393
|
}
|
|
14109
14394
|
};
|
|
14110
14395
|
|
|
@@ -14621,6 +14906,12 @@ messages.control.AuthenticationMessage = function () {
|
|
|
14621
14906
|
*/
|
|
14622
14907
|
this.authenticationMethod = null;
|
|
14623
14908
|
|
|
14909
|
+
/**
|
|
14910
|
+
* Auth WMID if using enterprise token auth method we need to have both wmid and authorization.
|
|
14911
|
+
* @type {String}
|
|
14912
|
+
*/
|
|
14913
|
+
this.wmid = null;
|
|
14914
|
+
|
|
14624
14915
|
/**
|
|
14625
14916
|
* Auth token.
|
|
14626
14917
|
* @type {String}
|