@quotemedia.com/streamer 2.27.0 → 2.31.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/{enduser-example.html → examples/enduser-example.html} +2 -1
- package/{enterprise-token-example.html → examples/enterprise-token-example.html} +2 -1
- package/{reconnect-example.html → examples/reconnect-example.html} +43 -11
- package/{subscription-example.html → examples/subscription-example.html} +2 -1
- package/{user-access-token-example.html → examples/user-access-token-example.html} +1 -1
- package/{wmid-example.html → examples/wmid-example.html} +2 -1
- package/package.json +1 -1
- package/{qmci-streamer-2.27.0.js → qmci-streamer-2.31.0.js} +492 -70
- package/{qmci-streamer-2.27.0.min.js → qmci-streamer-2.31.0.min.js} +11 -11
|
@@ -22,12 +22,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
22
22
|
|
|
23
23
|
var Connection = function () {
|
|
24
24
|
function Connection(createTransmitter, openSocket, log) {
|
|
25
|
+
var maxReconnectAttempts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 3;
|
|
26
|
+
|
|
25
27
|
_classCallCheck(this, Connection);
|
|
26
28
|
|
|
27
29
|
this.openSocket = openSocket;
|
|
28
30
|
this.createTransmitter = createTransmitter;
|
|
29
31
|
this.log = (0, _logging.asLogger)(log);
|
|
30
32
|
this.events = new _EventSupport2["default"](this);
|
|
33
|
+
this.currentConn = '';
|
|
34
|
+
//Max number of times that the client will try to reopen per loop
|
|
35
|
+
this.maxReconnectAttempts = maxReconnectAttempts;
|
|
36
|
+
//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.
|
|
37
|
+
//probably means that an unhandled loop was reached
|
|
38
|
+
this.maxReconnectsTotal = 3;
|
|
39
|
+
this.isFirstConnection = true;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
Connection.prototype.open = function open() {
|
|
@@ -39,17 +48,32 @@ var Connection = function () {
|
|
|
39
48
|
}
|
|
40
49
|
};
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
//Check to avoid creating unnecessary events and objects
|
|
52
|
+
if (this.isFirstConnection) {
|
|
53
|
+
this.on("reopen", function (e) {
|
|
54
|
+
if (_this.isConnectionUp) {
|
|
55
|
+
var prevConn = _this.currentConn;
|
|
56
|
+
_this.currentConn = e.connectionId;
|
|
57
|
+
_this.events.fire("reconnect", events.event("Reconnection success", {
|
|
58
|
+
previousConnectionId: prevConn,
|
|
59
|
+
currentConnectionId: _this.currentConn
|
|
60
|
+
}));
|
|
61
|
+
} else {
|
|
62
|
+
_this.events.fire("error", e);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.transmitter = this.createTransmitter(socketProxy);
|
|
66
|
+
this.transmitter.on("sequence", function (seq) {
|
|
67
|
+
_this.events.fire("sequence", seq);
|
|
68
|
+
}).on("message", function (message) {
|
|
69
|
+
_this.events.fire("message", message);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
49
72
|
this.socket = this.openSocket(function (request) {
|
|
50
73
|
_this.request = request;
|
|
51
74
|
var url = request.url;
|
|
52
75
|
|
|
76
|
+
_this.reconnect = false;
|
|
53
77
|
return {
|
|
54
78
|
onMessage: function onMessage(response) {
|
|
55
79
|
_this.transmitter.onMessage(response.responseBody);
|
|
@@ -58,22 +82,25 @@ var Connection = function () {
|
|
|
58
82
|
_this.transmitter.onMessage(response.responseBody);
|
|
59
83
|
},
|
|
60
84
|
onOpen: function onOpen(response) {
|
|
85
|
+
var code = response.status;
|
|
86
|
+
if (code !== 200) {
|
|
87
|
+
_this.reconnect = false;
|
|
88
|
+
} else {
|
|
89
|
+
_this.isConnectionUp = true;
|
|
90
|
+
}
|
|
61
91
|
var e = events.event("open", {
|
|
62
92
|
url: url,
|
|
63
|
-
code:
|
|
64
|
-
transport: response.transport
|
|
93
|
+
code: code,
|
|
94
|
+
transport: response.transport,
|
|
95
|
+
connectionId: response.request.uuid
|
|
65
96
|
});
|
|
66
97
|
_this.log.info(e);
|
|
67
98
|
_this.events.fire("open", e);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
transport: response.transport
|
|
74
|
-
});
|
|
75
|
-
response.maxReconnectOnClose--;
|
|
76
|
-
_this.log.info(e);
|
|
99
|
+
if (!_this.isFirstConnection) {
|
|
100
|
+
_this.maxReconnectsTotal--;
|
|
101
|
+
_this.events.fire("reopen", e);
|
|
102
|
+
}
|
|
103
|
+
_this.currentConn = response.request.uuid;
|
|
77
104
|
},
|
|
78
105
|
onTransportFailure: function onTransportFailure(reason, request) {
|
|
79
106
|
var e = events.error("Transport failure", {
|
|
@@ -84,6 +111,9 @@ var Connection = function () {
|
|
|
84
111
|
});
|
|
85
112
|
_this.log.error(reason);
|
|
86
113
|
_this.events.fire("error", e);
|
|
114
|
+
if (_this.isReconnect()) {
|
|
115
|
+
_this.reconnect = true;
|
|
116
|
+
}
|
|
87
117
|
},
|
|
88
118
|
onError: function onError(response) {
|
|
89
119
|
var reason = response.reason || response.reasonPhrase;
|
|
@@ -111,6 +141,11 @@ var Connection = function () {
|
|
|
111
141
|
code = 200;
|
|
112
142
|
reason = "Unsubscribed";
|
|
113
143
|
}
|
|
144
|
+
//When 501 code is sent it could mean that the server is down, therefore do not continue trying to reconnect
|
|
145
|
+
if (code === 501 || code === 401 || code === 403 || code === 452) {
|
|
146
|
+
_this.log.info("Unable to reconnect with code: " + msg.code + ", reason: " + msg.reason);
|
|
147
|
+
_this.reconnect = false;
|
|
148
|
+
}
|
|
114
149
|
|
|
115
150
|
var e = events.close({
|
|
116
151
|
url: url,
|
|
@@ -118,6 +153,9 @@ var Connection = function () {
|
|
|
118
153
|
code: code,
|
|
119
154
|
reason: reason
|
|
120
155
|
});
|
|
156
|
+
_this.isConnectionUp = false;
|
|
157
|
+
//Need to reset this value since it seems to be causing issues with resubscribing
|
|
158
|
+
response.request.uuid = 0;
|
|
121
159
|
_this.log.info(e);
|
|
122
160
|
_this.events.fire("close", e);
|
|
123
161
|
},
|
|
@@ -130,7 +168,7 @@ var Connection = function () {
|
|
|
130
168
|
_this.events.fire("slow", e);
|
|
131
169
|
}
|
|
132
170
|
};
|
|
133
|
-
});
|
|
171
|
+
}, this.currentConn);
|
|
134
172
|
};
|
|
135
173
|
|
|
136
174
|
Connection.prototype.close = function close() {
|
|
@@ -138,6 +176,9 @@ var Connection = function () {
|
|
|
138
176
|
try {
|
|
139
177
|
this.socket.close();
|
|
140
178
|
this.socket = null;
|
|
179
|
+
if (this.reconnect) {
|
|
180
|
+
this.tryReopen();
|
|
181
|
+
}
|
|
141
182
|
} catch (err) {
|
|
142
183
|
this.events.fire("error", events.error("Error closing", {
|
|
143
184
|
reason: err.message,
|
|
@@ -148,6 +189,43 @@ var Connection = function () {
|
|
|
148
189
|
}
|
|
149
190
|
};
|
|
150
191
|
|
|
192
|
+
Connection.prototype.tryReopen = function tryReopen() {
|
|
193
|
+
var _this2 = this;
|
|
194
|
+
|
|
195
|
+
if (this.isConnectionUp || this.maxReconnectsTotal <= 0) {
|
|
196
|
+
this.log.error("Connection is already open or max reconnects was reached, won't try to reconnect");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.isFirstConnection = false;
|
|
200
|
+
var currentAttempts = this.maxReconnectAttempts;
|
|
201
|
+
var reopenInterval = setInterval(function () {
|
|
202
|
+
if (currentAttempts <= 0) {
|
|
203
|
+
_this2.reconnect = false;
|
|
204
|
+
_this2.log.error("Error while reconnecting. No attempts left.");
|
|
205
|
+
//if maxattempts was reached and no connection was open, exit.
|
|
206
|
+
_this2.maxReconnectAttempts = 0;
|
|
207
|
+
clearInterval(reopenInterval);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (_this2.isConnectionUp || !_this2.reconnect) {
|
|
211
|
+
clearInterval(reopenInterval);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
_this2.log.info("Attempting reconnect. Attempts left: " + currentAttempts);
|
|
215
|
+
_this2.reopen(currentAttempts);
|
|
216
|
+
currentAttempts--;
|
|
217
|
+
}, 500);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
Connection.prototype.reopen = function reopen(attempt) {
|
|
221
|
+
try {
|
|
222
|
+
this.open();
|
|
223
|
+
} catch (exception) {
|
|
224
|
+
this.log.warn("There was an error while reopening attempt #" + attempt);
|
|
225
|
+
this.events.fire("error", exception);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
151
229
|
Connection.prototype.send = function send(message) {
|
|
152
230
|
try {
|
|
153
231
|
this.transmitter.send(message);
|
|
@@ -160,6 +238,14 @@ var Connection = function () {
|
|
|
160
238
|
}
|
|
161
239
|
};
|
|
162
240
|
|
|
241
|
+
Connection.prototype.isReconnect = function isReconnect() {
|
|
242
|
+
return this.request.headers['x-Stream-isReconnect'];
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
Connection.prototype.setReconnect = function setReconnect(doReconnect) {
|
|
246
|
+
this.reconnect = doReconnect;
|
|
247
|
+
};
|
|
248
|
+
|
|
163
249
|
Connection.prototype.setServer = function setServer(server) {
|
|
164
250
|
this.request.headers['X-Stream-Instance'] = server;
|
|
165
251
|
};
|
|
@@ -168,6 +254,10 @@ var Connection = function () {
|
|
|
168
254
|
return this.socket == null;
|
|
169
255
|
};
|
|
170
256
|
|
|
257
|
+
Connection.prototype.getConnectionUp = function getConnectionUp() {
|
|
258
|
+
return this.isConnectionUp;
|
|
259
|
+
};
|
|
260
|
+
|
|
171
261
|
Connection.prototype.on = function on(event, callback) {
|
|
172
262
|
return this.events.on(event, callback);
|
|
173
263
|
};
|
|
@@ -444,6 +534,8 @@ var Stream = function () {
|
|
|
444
534
|
_this.pendingConnection(err);
|
|
445
535
|
}
|
|
446
536
|
_this.events.fire("error", err);
|
|
537
|
+
}).on("reconnect", function (msg) {
|
|
538
|
+
_this.reconnectSuccess(msg);
|
|
447
539
|
});
|
|
448
540
|
|
|
449
541
|
this.requestid = new _UShortId2["default"]();
|
|
@@ -456,6 +548,7 @@ var Stream = function () {
|
|
|
456
548
|
this.pendingNewsUnsubscriptions = {};
|
|
457
549
|
this.pendingAlertSubscription = {};
|
|
458
550
|
this.pendingTradeSubscription = {};
|
|
551
|
+
this.pendingTradeUnsubscription = {};
|
|
459
552
|
|
|
460
553
|
this.on("error", function (err) {
|
|
461
554
|
_this.log.warn(err);
|
|
@@ -473,6 +566,11 @@ var Stream = function () {
|
|
|
473
566
|
}
|
|
474
567
|
};
|
|
475
568
|
|
|
569
|
+
Stream.prototype.reconnectSuccess = function reconnectSuccess(msg) {
|
|
570
|
+
this.events.fire("reconnectSuccess", msg);
|
|
571
|
+
this.log.info("Successfull reconnection. Previous Id: " + msg.previousConnectionId + " Current Id = " + msg.currentConnectionId);
|
|
572
|
+
};
|
|
573
|
+
|
|
476
574
|
Stream.prototype.on = function on(event, listener) {
|
|
477
575
|
return this.events.on(event, listener);
|
|
478
576
|
};
|
|
@@ -653,7 +751,7 @@ var Stream = function () {
|
|
|
653
751
|
this.send(request);
|
|
654
752
|
};
|
|
655
753
|
|
|
656
|
-
Stream.prototype.subscribeTrade = function subscribeTrade(
|
|
754
|
+
Stream.prototype.subscribeTrade = function subscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
|
|
657
755
|
var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
|
|
658
756
|
var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
|
|
659
757
|
|
|
@@ -671,11 +769,11 @@ var Stream = function () {
|
|
|
671
769
|
mimetype: this.format,
|
|
672
770
|
callback: callback,
|
|
673
771
|
result: {
|
|
674
|
-
|
|
772
|
+
notificationType: ""
|
|
675
773
|
}
|
|
676
774
|
};
|
|
677
775
|
|
|
678
|
-
var request = this.buildTradeSubscribeRequest(
|
|
776
|
+
var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.SUBSCRIBE);
|
|
679
777
|
var id = this.requestid.next();
|
|
680
778
|
tradeSub.id.push(id);
|
|
681
779
|
this.pendingTradeSubscription[id] = tradeSub;
|
|
@@ -889,6 +987,37 @@ var Stream = function () {
|
|
|
889
987
|
this.send(request);
|
|
890
988
|
};
|
|
891
989
|
|
|
990
|
+
Stream.prototype.unsubscribeTrade = function unsubscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
|
|
991
|
+
var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
|
|
992
|
+
var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
|
|
993
|
+
|
|
994
|
+
if (this.isClosed()) {
|
|
995
|
+
var event = events.error("Stream is disconnected", {
|
|
996
|
+
code: -1,
|
|
997
|
+
reason: "Already disconnected"
|
|
998
|
+
});
|
|
999
|
+
this.events.fire("error", event);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
var tradeSub = {
|
|
1004
|
+
id: [],
|
|
1005
|
+
mimetype: this.format,
|
|
1006
|
+
callback: callback,
|
|
1007
|
+
result: {
|
|
1008
|
+
notificationType: ""
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.UNSUBSCRIBE);
|
|
1013
|
+
var id = this.requestid.next();
|
|
1014
|
+
tradeSub.id.push(id);
|
|
1015
|
+
this.pendingTradeUnsubscription[id] = tradeSub;
|
|
1016
|
+
request.id = id;
|
|
1017
|
+
|
|
1018
|
+
this.send(request);
|
|
1019
|
+
};
|
|
1020
|
+
|
|
892
1021
|
Stream.prototype._handlejsonmsg = function _handlejsonmsg(msg) {
|
|
893
1022
|
if ((0, _streamerUtils.iscontrolmessage)(msg)) {
|
|
894
1023
|
this.handlectrlmsg(msg);
|
|
@@ -969,9 +1098,10 @@ var Stream = function () {
|
|
|
969
1098
|
return msg;
|
|
970
1099
|
};
|
|
971
1100
|
|
|
972
|
-
Stream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(
|
|
1101
|
+
Stream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(notificationType, sub, action) {
|
|
973
1102
|
var msg = new _streamerApi.messages.control.TradeSubscribeMessage();
|
|
974
|
-
msg.
|
|
1103
|
+
msg.action = action;
|
|
1104
|
+
msg.notificationType = notificationType;
|
|
975
1105
|
msg.mimetype = sub.mimetype;
|
|
976
1106
|
return msg;
|
|
977
1107
|
};
|
|
@@ -1030,6 +1160,9 @@ var Stream = function () {
|
|
|
1030
1160
|
case _streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_RESPONSE:
|
|
1031
1161
|
this.onNewsCmdFilterResponse(msg);
|
|
1032
1162
|
break;
|
|
1163
|
+
case _streamerApi.messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE:
|
|
1164
|
+
this.onTradeUnsubscribeResponse(msg);
|
|
1165
|
+
break;
|
|
1033
1166
|
case _streamerApi.messages.MessageTypeNames.ctrl.CONNECT_RESPONSE:
|
|
1034
1167
|
this.onConnectResponse(msg);
|
|
1035
1168
|
break;
|
|
@@ -1048,6 +1181,12 @@ var Stream = function () {
|
|
|
1048
1181
|
case _streamerApi.messages.MessageTypeNames.ctrl.RESUBSCRIBE_MESSAGE:
|
|
1049
1182
|
this.onResubscribeMessage(msg);
|
|
1050
1183
|
break;
|
|
1184
|
+
case _streamerApi.messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE:
|
|
1185
|
+
this.onReconnectMessage(msg);
|
|
1186
|
+
break;
|
|
1187
|
+
case _streamerApi.messages.MessageTypeNames.ctrl.MISSED_DATA_SENT:
|
|
1188
|
+
this.onMissedDataSent(msg);
|
|
1189
|
+
break;
|
|
1051
1190
|
}
|
|
1052
1191
|
};
|
|
1053
1192
|
|
|
@@ -1320,9 +1459,9 @@ var Stream = function () {
|
|
|
1320
1459
|
|
|
1321
1460
|
var result = tradeSub.result;
|
|
1322
1461
|
|
|
1323
|
-
if (msg.
|
|
1324
|
-
this.log.debug('Trade ' + msg.
|
|
1325
|
-
result.
|
|
1462
|
+
if (msg.notificationType) {
|
|
1463
|
+
this.log.debug('Trade ' + msg.notificationType);
|
|
1464
|
+
result.notificationType = msg.notificationType;
|
|
1326
1465
|
}
|
|
1327
1466
|
|
|
1328
1467
|
if (tradeSub.id.length === 0) {
|
|
@@ -1381,6 +1520,41 @@ var Stream = function () {
|
|
|
1381
1520
|
}
|
|
1382
1521
|
};
|
|
1383
1522
|
|
|
1523
|
+
Stream.prototype.onTradeUnsubscribeResponse = function onTradeUnsubscribeResponse(msg) {
|
|
1524
|
+
var tradeSub = this.pendingTradeUnsubscription[msg.__id];
|
|
1525
|
+
var callback = tradeSub.callback;
|
|
1526
|
+
|
|
1527
|
+
(0, _utils.removeFromArray)(tradeSub.id, msg.__id);
|
|
1528
|
+
delete this.pendingTradeUnsubscription[msg.__id];
|
|
1529
|
+
|
|
1530
|
+
console.log(msg);
|
|
1531
|
+
if (msg.code != 200 && !tradeSub.failed) {
|
|
1532
|
+
tradeSub.failed = true;
|
|
1533
|
+
var event = events.error("Error unsubscribing", {
|
|
1534
|
+
code: msg.code,
|
|
1535
|
+
reason: msg.reason
|
|
1536
|
+
});
|
|
1537
|
+
this.events.fire("error", event);
|
|
1538
|
+
if (callback) {
|
|
1539
|
+
tradeSub.callback(event);
|
|
1540
|
+
}
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
var result = tradeSub.result;
|
|
1545
|
+
|
|
1546
|
+
if (msg.notificationType) {
|
|
1547
|
+
this.log.debug('Trade ' + msg.notificationType);
|
|
1548
|
+
result.notificationType = msg.notificationType;
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
if (tradeSub.id.length === 0) {
|
|
1552
|
+
if (callback) {
|
|
1553
|
+
callback(null, tradeSub.result);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1384
1558
|
Stream.prototype.onNewsCmdFilterRefreshResponse = function onNewsCmdFilterRefreshResponse(msg) {
|
|
1385
1559
|
console.log("msg", msg);
|
|
1386
1560
|
if (msg.code != 200) {
|
|
@@ -1472,8 +1646,21 @@ var Stream = function () {
|
|
|
1472
1646
|
}
|
|
1473
1647
|
};
|
|
1474
1648
|
|
|
1649
|
+
Stream.prototype.onReconnectMessage = function onReconnectMessage(msg) {
|
|
1650
|
+
if (msg.code !== 200) {
|
|
1651
|
+
var event = events.error("Reconnection Failed", {
|
|
1652
|
+
code: msg.code,
|
|
1653
|
+
reason: msg.reason
|
|
1654
|
+
});
|
|
1655
|
+
this.events.fire("error", event);
|
|
1656
|
+
this.doClose(event);
|
|
1657
|
+
}
|
|
1658
|
+
this.events.fire("reconnectMessage", msg);
|
|
1659
|
+
console.log(msg);
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1475
1662
|
Stream.prototype.onConnectResponse = function onConnectResponse(msg) {
|
|
1476
|
-
if (msg.code
|
|
1663
|
+
if (msg.code !== 200) {
|
|
1477
1664
|
var event = events.error("Connection failed", {
|
|
1478
1665
|
code: msg.code,
|
|
1479
1666
|
reason: msg.reason
|
|
@@ -1541,6 +1728,11 @@ var Stream = function () {
|
|
|
1541
1728
|
this.events.fire("resubscribeMessage", msg);
|
|
1542
1729
|
};
|
|
1543
1730
|
|
|
1731
|
+
Stream.prototype.onMissedDataSent = function onMissedDataSent(msg) {
|
|
1732
|
+
this.log.debug(_formatting.msgfmt.fmt(msg));
|
|
1733
|
+
this.events.fire("missedDataSent", msg);
|
|
1734
|
+
};
|
|
1735
|
+
|
|
1544
1736
|
Stream.prototype._handledatamsg = function _handledatamsg(msg) {
|
|
1545
1737
|
this.events.fire("message", msg);
|
|
1546
1738
|
};
|
|
@@ -1556,8 +1748,29 @@ var Stream = function () {
|
|
|
1556
1748
|
if (!this.isClosed()) {
|
|
1557
1749
|
var conn = this.conn;
|
|
1558
1750
|
this.conn = null;
|
|
1559
|
-
this.events.fire("close", msg);
|
|
1560
1751
|
conn.close();
|
|
1752
|
+
this.events.fire("close", msg);
|
|
1753
|
+
if (conn.isReconnect()) {
|
|
1754
|
+
//Will need to reset the events since they duplicate each time it reconnects.
|
|
1755
|
+
this.events = new _EventSupport2["default"]();
|
|
1756
|
+
this.conn = conn;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
Stream.prototype.performReconnect = function performReconnect(callback) {
|
|
1762
|
+
if (this.conn != null && this.conn.isReconnect()) {
|
|
1763
|
+
if (this.conn.getConnectionUp()) {
|
|
1764
|
+
this.log.warn("Connection is not closed and won't try reconnect.");
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
this.conn.setReconnect(true);
|
|
1768
|
+
this.conn.tryReopen();
|
|
1769
|
+
if (callback) {
|
|
1770
|
+
callback();
|
|
1771
|
+
}
|
|
1772
|
+
} else {
|
|
1773
|
+
this.log.warn("Reconnect flag is set to false");
|
|
1561
1774
|
}
|
|
1562
1775
|
};
|
|
1563
1776
|
|
|
@@ -1658,30 +1871,24 @@ Object.assign(Streamer, {
|
|
|
1658
1871
|
},
|
|
1659
1872
|
|
|
1660
1873
|
openStomp: function openStomp(_config, callback) {
|
|
1661
|
-
|
|
1662
|
-
var stompHostConfig = ["http://localhost:7000", "https://qa.quotemedia.com/cache"];
|
|
1663
|
-
if (stompHostConfig.includes(_config.host)) {
|
|
1664
|
-
initLogger();
|
|
1874
|
+
initLogger();
|
|
1665
1875
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1876
|
+
var credentials = void 0;
|
|
1877
|
+
try {
|
|
1878
|
+
credentials = (0, _AuthService.asCredentials)(_config.credentials);
|
|
1879
|
+
} catch (e) {
|
|
1880
|
+
callback(e);
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1673
1883
|
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1884
|
+
var hostProtocol = _config.host.split('//');
|
|
1885
|
+
var wsProtocol = hostProtocol[0] === "http:" ? "ws://" : "wss://";
|
|
1886
|
+
var config = Object.assign({}, _config);
|
|
1887
|
+
config.credentials = credentials;
|
|
1888
|
+
config.format = config.format || "application/json";
|
|
1889
|
+
config.url = wsProtocol + hostProtocol[1];
|
|
1680
1890
|
|
|
1681
|
-
|
|
1682
|
-
} else {
|
|
1683
|
-
callback("ERROR: Stomp Connection is only turn on in Local and QA");
|
|
1684
|
-
}
|
|
1891
|
+
new _StompStreamingService2["default"](_http2["default"], _stomp2["default"], logger, config).openStompStream(callback);
|
|
1685
1892
|
},
|
|
1686
1893
|
|
|
1687
1894
|
ping: function ping(host, callback) {
|
|
@@ -1761,6 +1968,7 @@ var StreamingService = function () {
|
|
|
1761
1968
|
this.atmo = atmosphere;
|
|
1762
1969
|
this.log = (0, _logging.asLogger)(log);
|
|
1763
1970
|
this.config = config || {};
|
|
1971
|
+
this.maxReconnectAttempts = this.config.maxReconnectAttempts;
|
|
1764
1972
|
|
|
1765
1973
|
this.format = this.config.format;
|
|
1766
1974
|
if (this.config.format === 'application/json') {
|
|
@@ -1786,7 +1994,7 @@ var StreamingService = function () {
|
|
|
1786
1994
|
}
|
|
1787
1995
|
}
|
|
1788
1996
|
|
|
1789
|
-
StreamingService.prototype.openSocket = function openSocket(handlers) {
|
|
1997
|
+
StreamingService.prototype.openSocket = function openSocket(handlers, connectionId) {
|
|
1790
1998
|
var headers = {
|
|
1791
1999
|
'X-Stream-Version': _streamerApi.VERSION,
|
|
1792
2000
|
'X-Stream-Lib': _streamerApi.LIBRARY_NAME
|
|
@@ -1797,6 +2005,9 @@ var StreamingService = function () {
|
|
|
1797
2005
|
headers['X-Stream-Conflation'] = _conflation;
|
|
1798
2006
|
}
|
|
1799
2007
|
|
|
2008
|
+
if (connectionId != null && connectionId !== '') {
|
|
2009
|
+
headers['X-Stream-Previous-Connection-Id'] = connectionId;
|
|
2010
|
+
}
|
|
1800
2011
|
var _rejectExcessiveConnection = this.config.rejectExcessiveConnection;
|
|
1801
2012
|
if (_rejectExcessiveConnection != null && _rejectExcessiveConnection !== '') {
|
|
1802
2013
|
headers['X-Stream-Reject'] = _rejectExcessiveConnection;
|
|
@@ -1815,6 +2026,22 @@ var StreamingService = function () {
|
|
|
1815
2026
|
headers['X-Stream-UpdatesOnly'] = true;
|
|
1816
2027
|
}
|
|
1817
2028
|
|
|
2029
|
+
var _isReconnect = this.config.isReconnect;
|
|
2030
|
+
if (_isReconnect != null && _isReconnect !== '') {
|
|
2031
|
+
headers['x-Stream-isReconnect'] = _isReconnect;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
var _alwaysReconnect = this.config.alwaysReconnect;
|
|
2035
|
+
if (_alwaysReconnect != null && _alwaysReconnect !== '') {
|
|
2036
|
+
headers['x-Stream-isAlwaysReopen'] = _alwaysReconnect;
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
if (this.config.isMissedData === 'ALL') {
|
|
2040
|
+
headers['X-Stream-isReceiveAllMissedData'] = true;
|
|
2041
|
+
} else if (this.config.isMissedData === 'LATEST') {
|
|
2042
|
+
headers['X-Stream-isReceiveLatestMissedData'] = true;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
1818
2045
|
Object.assign(headers, this.config.credentials.getHeaders());
|
|
1819
2046
|
|
|
1820
2047
|
var request = {
|
|
@@ -1846,9 +2073,9 @@ var StreamingService = function () {
|
|
|
1846
2073
|
|
|
1847
2074
|
return new _Connection2["default"](function (socket) {
|
|
1848
2075
|
return _this2.createTransmitter(socket);
|
|
1849
|
-
}, function (handlers) {
|
|
1850
|
-
return _this2.openSocket(handlers);
|
|
1851
|
-
}, this.
|
|
2076
|
+
}, function (handlers, connectionId) {
|
|
2077
|
+
return _this2.openSocket(handlers, connectionId);
|
|
2078
|
+
}, this.log, this.maxReconnectAttempts);
|
|
1852
2079
|
};
|
|
1853
2080
|
|
|
1854
2081
|
StreamingService.prototype.openStream = function openStream(callback) {
|
|
@@ -5558,6 +5785,7 @@ var EnduserAuthService = function () {
|
|
|
5558
5785
|
this.http = http;
|
|
5559
5786
|
this.host = config.host || "app.quotemedia.com";
|
|
5560
5787
|
this.credentials = credentials;
|
|
5788
|
+
this.application = config.application;
|
|
5561
5789
|
this.method = "POST";
|
|
5562
5790
|
}
|
|
5563
5791
|
|
|
@@ -5566,7 +5794,7 @@ var EnduserAuthService = function () {
|
|
|
5566
5794
|
};
|
|
5567
5795
|
|
|
5568
5796
|
EnduserAuthService.prototype.login_POST = function login_POST(callback) {
|
|
5569
|
-
var url = this.host + AUTHSERVICEURLS.authenticate_post;
|
|
5797
|
+
var url = this.host + AUTHSERVICEURLS.authenticate_post + (this.application ? "&application=" + this.application : "");
|
|
5570
5798
|
var req = {
|
|
5571
5799
|
wmId: this.credentials.wmid,
|
|
5572
5800
|
username: this.credentials.username,
|
|
@@ -5666,6 +5894,9 @@ fmt.Formatter = function () {
|
|
|
5666
5894
|
this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.NEWS_UNSUBSCRIBE_RESPONSE] = this._fmtnewsunsubscriberesponse;
|
|
5667
5895
|
this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_REFRESH_RESPONSE] = this._fmtnewscmdfilterrefreshresponse;
|
|
5668
5896
|
this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_RESPONSE] = this._fmtnewscmdfilterresponse;
|
|
5897
|
+
this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE] = this._fmttradeunsubscriberesponse;
|
|
5898
|
+
this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE] = this._fmtreconnectresponse;
|
|
5899
|
+
this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.MISSED_DATA_SENT] = this._fmtmisseddatasent;
|
|
5669
5900
|
|
|
5670
5901
|
//
|
|
5671
5902
|
this.formatters[_streamerApi.messages.MessageTypeNames.data.QUOTE] = this._fmtquote;
|
|
@@ -5817,6 +6048,8 @@ fmt.Formatter.prototype._fmtpricedata = function (val) {
|
|
|
5817
6048
|
s.append(val.postMarketPercentChange);
|
|
5818
6049
|
s.sep();
|
|
5819
6050
|
s.append(val.lastTradeExcode);
|
|
6051
|
+
s.sep();
|
|
6052
|
+
s.append(val.currencyID);
|
|
5820
6053
|
return s.toString();
|
|
5821
6054
|
};
|
|
5822
6055
|
fmt.Formatter.prototype._fmtlastsale = function (val) {
|
|
@@ -6456,6 +6689,13 @@ fmt.Formatter.prototype._fmtexchangeunsubscriberesponse = function (val) {
|
|
|
6456
6689
|
return s.toString();
|
|
6457
6690
|
};
|
|
6458
6691
|
|
|
6692
|
+
fmt.Formatter.prototype._fmttradeunsubscriberesponse = function (val) {
|
|
6693
|
+
var s = new fmt.StringBuilder();
|
|
6694
|
+
s.append('TRADE UNSUBSCRIBED');
|
|
6695
|
+
// TODO
|
|
6696
|
+
return s.toString();
|
|
6697
|
+
};
|
|
6698
|
+
|
|
6459
6699
|
fmt.Formatter.prototype._fmtconnectresponse = function (val) {
|
|
6460
6700
|
var s = new fmt.StringBuilder();
|
|
6461
6701
|
s.append('CONNECT');
|
|
@@ -6476,6 +6716,26 @@ fmt.Formatter.prototype._fmtconnectresponse = function (val) {
|
|
|
6476
6716
|
return s.toString();
|
|
6477
6717
|
};
|
|
6478
6718
|
|
|
6719
|
+
fmt.Formatter.prototype._fmtreconnectresponse = function (val) {
|
|
6720
|
+
var s = new fmt.StringBuilder();
|
|
6721
|
+
s.append('RECONNECT');
|
|
6722
|
+
s.sep();
|
|
6723
|
+
s.append(val.version);
|
|
6724
|
+
s.sep();
|
|
6725
|
+
s.append(val.flowControlCheckInterval);
|
|
6726
|
+
s.sep();
|
|
6727
|
+
s.append(val.serverInstance);
|
|
6728
|
+
s.sep();
|
|
6729
|
+
s.append(val.conflationMs);
|
|
6730
|
+
s.sep();
|
|
6731
|
+
s.append(val.rejectExcessiveConnection);
|
|
6732
|
+
s.sep();
|
|
6733
|
+
s.append(val.maxEntitlementsPerSubscription);
|
|
6734
|
+
s.sep();
|
|
6735
|
+
s.sep(val.entitlements);
|
|
6736
|
+
return s.toString();
|
|
6737
|
+
};
|
|
6738
|
+
|
|
6479
6739
|
fmt.Formatter.prototype._fmtconnectionclose = function (val) {
|
|
6480
6740
|
var s = new fmt.StringBuilder();
|
|
6481
6741
|
s.append('CLOSE');
|
|
@@ -6565,6 +6825,16 @@ fmt.Formatter.prototype.__baseresponse = function (val, s) {
|
|
|
6565
6825
|
s.append(val.reason);
|
|
6566
6826
|
};
|
|
6567
6827
|
|
|
6828
|
+
fmt.Formatter.prototype._fmtmisseddatasent = function (val) {
|
|
6829
|
+
var s = new fmt.StringBuilder();
|
|
6830
|
+
s.append("MISSED DATA SENT");
|
|
6831
|
+
s.sep();
|
|
6832
|
+
s.datetime(val.timestamp);
|
|
6833
|
+
s.sep();
|
|
6834
|
+
s.append(val.requestId);
|
|
6835
|
+
return s.toString();
|
|
6836
|
+
};
|
|
6837
|
+
|
|
6568
6838
|
/**
|
|
6569
6839
|
* Create a new sting builder.
|
|
6570
6840
|
* @constructor
|
|
@@ -10242,6 +10512,7 @@ var PricedataDecoder = function () {
|
|
|
10242
10512
|
out.postMarketChange = _Qitch2["default"].dec8double(src, offset + def.POSTMARKETCHANGE_OFFSET);
|
|
10243
10513
|
out.postMarketPercentChange = this._postmarketPercentChange(out);
|
|
10244
10514
|
out.lastTradeExcode = _Qitch2["default"].excode(src, offset + def.LASTTRADEEXCODE_OFFSET);
|
|
10515
|
+
out.currencyID = _Qitch2["default"].currencyid(src, offset + def.CURRENCYID_OFFSET);
|
|
10245
10516
|
|
|
10246
10517
|
return out;
|
|
10247
10518
|
};
|
|
@@ -11159,7 +11430,7 @@ var LENGTH = exports.LENGTH = SELLBLOCKTRANSACTIONS_OFFSET + _QitchConstants.INT
|
|
|
11159
11430
|
"use strict";
|
|
11160
11431
|
|
|
11161
11432
|
exports.__esModule = true;
|
|
11162
|
-
exports.PricedataFlags = exports.LENGTH = exports.DECIMALLASTTRADESIZE_OFFSET = exports.DECIMALPOSTMARKETVOLUME_OFFSET = exports.DECIMALPREMARKETVOLUME_OFFSET = exports.DECIMALACCUMULATEDVOLUME_OFFSET = exports.LASTTRADEEXCODE_OFFSET = exports.POSTMARKETCHANGE_OFFSET = exports.POSTMARKETVOLUME_OFFSET = exports.POSTMARKETLASTPRICE_OFFSET = exports.POSTMARKETTRADETIME_OFFSET = exports.PREMARKETCHANGE_OFFSET = exports.PREMARKETVOLUME_OFFSET = exports.PREMARKETLASTPRICE_OFFSET = exports.PREMARKETTRADETIME_OFFSET = exports.TWAP_OFFSET = exports.VWAP_OFFSET = exports.FLAGS_OFFSET = exports.ACCUMULATEDTRADEVALUE_OFFSET = exports.TRADECOUNT_OFFSET = exports.CLOSE_OFFSET = exports.LASTTRADESIZE_OFFSET = exports.TICK_OFFSET = exports.LASTTRADETIME_OFFSET = exports.ACCUMULATEDVOLUME_OFFSET = exports.LOW_OFFSET = exports.HIGH_OFFSET = exports.OPEN_OFFSET = exports.PREVCLOSE_OFFSET = exports.LAST_OFFSET = exports.SYMBOL_OFFSET = exports.TIMESTAMP_OFFSET = exports.TYPEID = undefined;
|
|
11433
|
+
exports.PricedataFlags = exports.LENGTH = exports.CURRENCYID_OFFSET = exports.DECIMALLASTTRADESIZE_OFFSET = exports.DECIMALPOSTMARKETVOLUME_OFFSET = exports.DECIMALPREMARKETVOLUME_OFFSET = exports.DECIMALACCUMULATEDVOLUME_OFFSET = exports.LASTTRADEEXCODE_OFFSET = exports.POSTMARKETCHANGE_OFFSET = exports.POSTMARKETVOLUME_OFFSET = exports.POSTMARKETLASTPRICE_OFFSET = exports.POSTMARKETTRADETIME_OFFSET = exports.PREMARKETCHANGE_OFFSET = exports.PREMARKETVOLUME_OFFSET = exports.PREMARKETLASTPRICE_OFFSET = exports.PREMARKETTRADETIME_OFFSET = exports.TWAP_OFFSET = exports.VWAP_OFFSET = exports.FLAGS_OFFSET = exports.ACCUMULATEDTRADEVALUE_OFFSET = exports.TRADECOUNT_OFFSET = exports.CLOSE_OFFSET = exports.LASTTRADESIZE_OFFSET = exports.TICK_OFFSET = exports.LASTTRADETIME_OFFSET = exports.ACCUMULATEDVOLUME_OFFSET = exports.LOW_OFFSET = exports.HIGH_OFFSET = exports.OPEN_OFFSET = exports.PREVCLOSE_OFFSET = exports.LAST_OFFSET = exports.SYMBOL_OFFSET = exports.TIMESTAMP_OFFSET = exports.TYPEID = undefined;
|
|
11163
11434
|
|
|
11164
11435
|
var _QitchConstants = require("../QitchConstants");
|
|
11165
11436
|
|
|
@@ -11199,7 +11470,9 @@ var DECIMALPREMARKETVOLUME_OFFSET = exports.DECIMALPREMARKETVOLUME_OFFSET = DECI
|
|
|
11199
11470
|
var DECIMALPOSTMARKETVOLUME_OFFSET = exports.DECIMALPOSTMARKETVOLUME_OFFSET = DECIMALPREMARKETVOLUME_OFFSET + _QitchConstants.DOUBLE_LENGTH;
|
|
11200
11471
|
var DECIMALLASTTRADESIZE_OFFSET = exports.DECIMALLASTTRADESIZE_OFFSET = DECIMALPOSTMARKETVOLUME_OFFSET + _QitchConstants.DOUBLE_LENGTH;
|
|
11201
11472
|
|
|
11202
|
-
var
|
|
11473
|
+
var CURRENCYID_OFFSET = exports.CURRENCYID_OFFSET = DECIMALLASTTRADESIZE_OFFSET + _QitchConstants.DOUBLE_LENGTH;
|
|
11474
|
+
|
|
11475
|
+
var LENGTH = exports.LENGTH = CURRENCYID_OFFSET + _QitchConstants.CURRENCYID_LENGTH;
|
|
11203
11476
|
|
|
11204
11477
|
var PricedataFlags = exports.PricedataFlags = function () {
|
|
11205
11478
|
function PricedataFlags() {
|
|
@@ -11415,6 +11688,10 @@ var TradeFlags = exports.TradeFlags = function () {
|
|
|
11415
11688
|
return bits & TradeFlags.prototype.CORRECTION_MASK;
|
|
11416
11689
|
};
|
|
11417
11690
|
|
|
11691
|
+
TradeFlags.isOutOfSequence = function isOutOfSequence(bits) {
|
|
11692
|
+
return bits & TradeFlags.prototype.OUTOFSEQUENCE_MASK;
|
|
11693
|
+
};
|
|
11694
|
+
|
|
11418
11695
|
return TradeFlags;
|
|
11419
11696
|
}();
|
|
11420
11697
|
|
|
@@ -11436,6 +11713,7 @@ TradeFlags.prototype.BLOCKTRADE_MASK = 0x00008000;
|
|
|
11436
11713
|
TradeFlags.prototype.IGNOREOPEN_MASK = 0x00000100;
|
|
11437
11714
|
TradeFlags.prototype.TRADETHROUGHEXEMPT = 0x00000200;
|
|
11438
11715
|
TradeFlags.prototype.CORRECTION_MASK = 0x08000000;
|
|
11716
|
+
TradeFlags.prototype.OUTOFSEQUENCE_MASK = 0x00000400;
|
|
11439
11717
|
}).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/qitch/marketDataDefinition/TradeDef.js","/lib/qitch/marketDataDefinition")
|
|
11440
11718
|
},{"../QitchConstants":26,"_process":119,"buffer":109,"timers":140}],87:[function(require,module,exports){
|
|
11441
11719
|
(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,setImmediate,clearImmediate,__filename,__dirname){
|
|
@@ -12351,6 +12629,7 @@ var StompStream = function () {
|
|
|
12351
12629
|
this.pendingNewsUnsubscriptions = {};
|
|
12352
12630
|
this.pendingAlertSubscription = {};
|
|
12353
12631
|
this.pendingTradeSubscription = {};
|
|
12632
|
+
this.pendingTradeUnsubscription = {};
|
|
12354
12633
|
|
|
12355
12634
|
this.on("error", function (err) {
|
|
12356
12635
|
_this.log.warn(err);
|
|
@@ -12548,7 +12827,7 @@ var StompStream = function () {
|
|
|
12548
12827
|
this.send(request);
|
|
12549
12828
|
};
|
|
12550
12829
|
|
|
12551
|
-
StompStream.prototype.subscribeTrade = function subscribeTrade(
|
|
12830
|
+
StompStream.prototype.subscribeTrade = function subscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
|
|
12552
12831
|
var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
|
|
12553
12832
|
var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
|
|
12554
12833
|
|
|
@@ -12566,11 +12845,11 @@ var StompStream = function () {
|
|
|
12566
12845
|
mimetype: this.format,
|
|
12567
12846
|
callback: callback,
|
|
12568
12847
|
result: {
|
|
12569
|
-
|
|
12848
|
+
notificationType: ""
|
|
12570
12849
|
}
|
|
12571
12850
|
};
|
|
12572
12851
|
|
|
12573
|
-
var request = this.buildTradeSubscribeRequest(
|
|
12852
|
+
var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.SUBSCRIBE);
|
|
12574
12853
|
var id = this.requestid.next();
|
|
12575
12854
|
tradeSub.id.push(id);
|
|
12576
12855
|
this.pendingTradeSubscription[id] = tradeSub;
|
|
@@ -12784,6 +13063,37 @@ var StompStream = function () {
|
|
|
12784
13063
|
this.send(request);
|
|
12785
13064
|
};
|
|
12786
13065
|
|
|
13066
|
+
StompStream.prototype.unsubscribeTrade = function unsubscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
|
|
13067
|
+
var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
|
|
13068
|
+
var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
|
|
13069
|
+
|
|
13070
|
+
if (this.isClosed()) {
|
|
13071
|
+
var event = events.error("Stream is disconnected", {
|
|
13072
|
+
code: -1,
|
|
13073
|
+
reason: "Already disconnected"
|
|
13074
|
+
});
|
|
13075
|
+
this.events.fire("error", event);
|
|
13076
|
+
return;
|
|
13077
|
+
}
|
|
13078
|
+
|
|
13079
|
+
var tradeSub = {
|
|
13080
|
+
id: [],
|
|
13081
|
+
mimetype: this.format,
|
|
13082
|
+
callback: callback,
|
|
13083
|
+
result: {
|
|
13084
|
+
notificationType: ""
|
|
13085
|
+
}
|
|
13086
|
+
};
|
|
13087
|
+
|
|
13088
|
+
var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.UNSUBSCRIBE);
|
|
13089
|
+
var id = this.requestid.next();
|
|
13090
|
+
tradeSub.id.push(id);
|
|
13091
|
+
this.pendingTradeUnsubscription[id] = tradeSub;
|
|
13092
|
+
request.id = id;
|
|
13093
|
+
|
|
13094
|
+
this.send(request);
|
|
13095
|
+
};
|
|
13096
|
+
|
|
12787
13097
|
StompStream.prototype._handlejsonmsg = function _handlejsonmsg(msg) {
|
|
12788
13098
|
if ((0, _streamerUtils.iscontrolmessage)(msg)) {
|
|
12789
13099
|
this.handlectrlmsg(msg);
|
|
@@ -12864,9 +13174,10 @@ var StompStream = function () {
|
|
|
12864
13174
|
return msg;
|
|
12865
13175
|
};
|
|
12866
13176
|
|
|
12867
|
-
StompStream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(
|
|
13177
|
+
StompStream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(notificationType, sub, action) {
|
|
12868
13178
|
var msg = new _streamerApi.messages.control.TradeSubscribeMessage();
|
|
12869
|
-
msg.
|
|
13179
|
+
msg.action = action;
|
|
13180
|
+
msg.notificationType = notificationType;
|
|
12870
13181
|
msg.mimetype = sub.mimetype;
|
|
12871
13182
|
return msg;
|
|
12872
13183
|
};
|
|
@@ -12925,6 +13236,9 @@ var StompStream = function () {
|
|
|
12925
13236
|
case _streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_RESPONSE:
|
|
12926
13237
|
this.onNewsCmdFilterResponse(msg);
|
|
12927
13238
|
break;
|
|
13239
|
+
case _streamerApi.messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE:
|
|
13240
|
+
this.onTradeUnsubscribeResponse(msg);
|
|
13241
|
+
break;
|
|
12928
13242
|
case _streamerApi.messages.MessageTypeNames.ctrl.CONNECT_RESPONSE:
|
|
12929
13243
|
this.onConnectResponse(msg);
|
|
12930
13244
|
break;
|
|
@@ -13218,9 +13532,9 @@ var StompStream = function () {
|
|
|
13218
13532
|
|
|
13219
13533
|
var result = tradeSub.result;
|
|
13220
13534
|
|
|
13221
|
-
if (msg.
|
|
13222
|
-
this.log.debug('Trade ' + msg.
|
|
13223
|
-
result.
|
|
13535
|
+
if (msg.notificationType) {
|
|
13536
|
+
this.log.debug('Trade ' + msg.notificationType);
|
|
13537
|
+
result.notificationType = msg.notificationType;
|
|
13224
13538
|
}
|
|
13225
13539
|
|
|
13226
13540
|
if (tradeSub.id.length === 0) {
|
|
@@ -13279,6 +13593,41 @@ var StompStream = function () {
|
|
|
13279
13593
|
}
|
|
13280
13594
|
};
|
|
13281
13595
|
|
|
13596
|
+
StompStream.prototype.onTradeUnsubscribeResponse = function onTradeUnsubscribeResponse(msg) {
|
|
13597
|
+
var tradeSub = this.pendingTradeUnsubscription[msg.__id];
|
|
13598
|
+
var callback = tradeSub.callback;
|
|
13599
|
+
|
|
13600
|
+
(0, _utils.removeFromArray)(tradeSub.id, msg.__id);
|
|
13601
|
+
delete this.pendingTradeUnsubscription[msg.__id];
|
|
13602
|
+
|
|
13603
|
+
console.log(msg);
|
|
13604
|
+
if (msg.code != 200 && !tradeSub.failed) {
|
|
13605
|
+
tradeSub.failed = true;
|
|
13606
|
+
var event = events.error("Error unsubscribing", {
|
|
13607
|
+
code: msg.code,
|
|
13608
|
+
reason: msg.reason
|
|
13609
|
+
});
|
|
13610
|
+
this.events.fire("error", event);
|
|
13611
|
+
if (callback) {
|
|
13612
|
+
tradeSub.callback(event);
|
|
13613
|
+
}
|
|
13614
|
+
return;
|
|
13615
|
+
}
|
|
13616
|
+
|
|
13617
|
+
var result = tradeSub.result;
|
|
13618
|
+
|
|
13619
|
+
if (msg.notificationType) {
|
|
13620
|
+
this.log.debug('Trade ' + msg.notificationType);
|
|
13621
|
+
result.notificationType = msg.notificationType;
|
|
13622
|
+
}
|
|
13623
|
+
|
|
13624
|
+
if (tradeSub.id.length === 0) {
|
|
13625
|
+
if (callback) {
|
|
13626
|
+
callback(null, tradeSub.result);
|
|
13627
|
+
}
|
|
13628
|
+
}
|
|
13629
|
+
};
|
|
13630
|
+
|
|
13282
13631
|
StompStream.prototype.onNewsCmdFilterRefreshResponse = function onNewsCmdFilterRefreshResponse(msg) {
|
|
13283
13632
|
console.log("msg", msg);
|
|
13284
13633
|
if (msg.code != 200) {
|
|
@@ -13592,12 +13941,12 @@ var StompStreamingService = function () {
|
|
|
13592
13941
|
handlers(headers).onMessage(responseMessage);
|
|
13593
13942
|
});
|
|
13594
13943
|
|
|
13595
|
-
stompClient.send("/stream/
|
|
13944
|
+
stompClient.send("/stream/message", headers, JSON.stringify(authMessage));
|
|
13596
13945
|
});
|
|
13597
13946
|
|
|
13598
13947
|
return {
|
|
13599
13948
|
send: function send(msg) {
|
|
13600
|
-
stompClient.send("/stream/
|
|
13949
|
+
stompClient.send("/stream/message", headers, msg);
|
|
13601
13950
|
},
|
|
13602
13951
|
close: function close() {
|
|
13603
13952
|
stompClient.disconnect();
|
|
@@ -13660,7 +14009,7 @@ exports.__esModule = true;
|
|
|
13660
14009
|
*/
|
|
13661
14010
|
|
|
13662
14011
|
var LIBRARY_NAME = exports.LIBRARY_NAME = "JavaScript";
|
|
13663
|
-
var VERSION = exports.VERSION = "2.
|
|
14012
|
+
var VERSION = exports.VERSION = "2.31.0";
|
|
13664
14013
|
|
|
13665
14014
|
/**
|
|
13666
14015
|
* Streamer message api namespace.
|
|
@@ -13724,7 +14073,10 @@ messages.MessageTypeNames = {
|
|
|
13724
14073
|
NEWS_CMD_FILTER_REFRESH_RESPONSE: 'C25',
|
|
13725
14074
|
NEWS_CMD_FILTER_RESPONSE: 'C26',
|
|
13726
14075
|
AUTHENTICATION: 'C27',
|
|
13727
|
-
OPEN_FLOW: 'C28'
|
|
14076
|
+
OPEN_FLOW: 'C28',
|
|
14077
|
+
RECONNECT_RESPONSE: 'C29',
|
|
14078
|
+
TRADE_UNSUBSCRIBE_RESPONSE: 'C30',
|
|
14079
|
+
MISSED_DATA_SENT: 'C31'
|
|
13728
14080
|
},
|
|
13729
14081
|
/**
|
|
13730
14082
|
* Name space for data message type identifiers.<br>
|
|
@@ -13960,11 +14312,18 @@ messages.control.AlertsSubUnsubMessage.prototype = new messages.control.CtrlMess
|
|
|
13960
14312
|
messages.control.TradeSubscribeMessage = function () {
|
|
13961
14313
|
this.init(messages.MessageTypeNames.ctrl.TRADE_SUBSCRIBE);
|
|
13962
14314
|
|
|
14315
|
+
/**
|
|
14316
|
+
* The action the server will taken when receiving this message.
|
|
14317
|
+
* @type {string}
|
|
14318
|
+
* @see exports.messages.control.Action
|
|
14319
|
+
*/
|
|
14320
|
+
this.action = null;
|
|
14321
|
+
|
|
13963
14322
|
/**
|
|
13964
14323
|
* The subscribe/un-subscribe for trade notifications.
|
|
13965
14324
|
* @type {Array.<string>}
|
|
13966
14325
|
*/
|
|
13967
|
-
this.
|
|
14326
|
+
this.notificationType = null;
|
|
13968
14327
|
|
|
13969
14328
|
/**
|
|
13970
14329
|
* Requested message mime-type format.
|
|
@@ -14083,6 +14442,15 @@ messages.control.NewsUnsubscribeResponse = function () {
|
|
|
14083
14442
|
};
|
|
14084
14443
|
messages.control.NewsUnsubscribeResponse.prototype = new messages.control.BaseResponse();
|
|
14085
14444
|
|
|
14445
|
+
/**
|
|
14446
|
+
* Creates Trade notification subscribe response message.
|
|
14447
|
+
* @constructor
|
|
14448
|
+
*/
|
|
14449
|
+
messages.control.TradeUnsubscribeResponse = function () {
|
|
14450
|
+
this.init(messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE);
|
|
14451
|
+
};
|
|
14452
|
+
|
|
14453
|
+
messages.control.TradeUnsubscribeResponse.prototype = new messages.control.BaseResponse();
|
|
14086
14454
|
/**
|
|
14087
14455
|
* Creates a stream entitlement info.
|
|
14088
14456
|
* @constructor
|
|
@@ -14142,6 +14510,44 @@ messages.control.ConnectResponse = function () {
|
|
|
14142
14510
|
};
|
|
14143
14511
|
messages.control.ConnectResponse.prototype = new messages.control.BaseResponse();
|
|
14144
14512
|
|
|
14513
|
+
/**
|
|
14514
|
+
* Creates a new reconnect response message
|
|
14515
|
+
* @constructor
|
|
14516
|
+
*/
|
|
14517
|
+
messages.control.ReconnectResponse = function () {
|
|
14518
|
+
undefined.init(messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE);
|
|
14519
|
+
|
|
14520
|
+
/**
|
|
14521
|
+
* The server version.
|
|
14522
|
+
* @type {string}
|
|
14523
|
+
*/
|
|
14524
|
+
undefined.version = null;
|
|
14525
|
+
|
|
14526
|
+
/**
|
|
14527
|
+
* The flow control check interval.
|
|
14528
|
+
* @type {number}
|
|
14529
|
+
*/
|
|
14530
|
+
undefined.flowControlCheckInterval = null;
|
|
14531
|
+
|
|
14532
|
+
/**
|
|
14533
|
+
* The server instance connected to.
|
|
14534
|
+
* @type {string}
|
|
14535
|
+
*/
|
|
14536
|
+
undefined.serverInstance = null;
|
|
14537
|
+
|
|
14538
|
+
/**
|
|
14539
|
+
* The conflation rate in milliseconds.
|
|
14540
|
+
* @type {number}
|
|
14541
|
+
*/
|
|
14542
|
+
undefined.conflationMs = null;
|
|
14543
|
+
|
|
14544
|
+
/**
|
|
14545
|
+
* The previous subscriptions
|
|
14546
|
+
* @type {Array.<messages.control.StreamEntitlement>}
|
|
14547
|
+
*/
|
|
14548
|
+
undefined.previousSubscriptions = null;
|
|
14549
|
+
};
|
|
14550
|
+
|
|
14145
14551
|
/**
|
|
14146
14552
|
* Creates a connection response message.
|
|
14147
14553
|
* @constructor
|
|
@@ -14317,6 +14723,22 @@ messages.control.ResubscribeMessage = function () {
|
|
|
14317
14723
|
};
|
|
14318
14724
|
messages.control.ResubscribeMessage.prototype = new messages.control.CtrlMessage();
|
|
14319
14725
|
|
|
14726
|
+
/**
|
|
14727
|
+
* Creates a Missed Data Sent response message.
|
|
14728
|
+
* @constructor
|
|
14729
|
+
*/
|
|
14730
|
+
messages.control.MissedDataSent = function () {
|
|
14731
|
+
this.init(messages.MessageTypeNames.ctrl.MISSED_DATA_SENT);
|
|
14732
|
+
|
|
14733
|
+
/**
|
|
14734
|
+
* The timestamp of message creation.
|
|
14735
|
+
* @type {number|JSBI} for connections with JSON format timestamp will be decoded as number,
|
|
14736
|
+
* for connections with QITCH format - {@link JSBI.BigInt}
|
|
14737
|
+
*/
|
|
14738
|
+
this.timestamp = null;
|
|
14739
|
+
};
|
|
14740
|
+
messages.control.MissedDataSent.prototype = new messages.control.CtrlMessage();
|
|
14741
|
+
|
|
14320
14742
|
/**
|
|
14321
14743
|
* Stream entitlement types.
|
|
14322
14744
|
* @enum
|