@quotemedia.com/streamer 2.27.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.
@@ -22,12 +22,30 @@ 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;
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
+ };
31
49
  }
32
50
 
33
51
  Connection.prototype.open = function open() {
@@ -39,17 +57,32 @@ var Connection = function () {
39
57
  }
40
58
  };
41
59
 
42
- this.transmitter = this.createTransmitter(socketProxy);
43
- this.transmitter.on("sequence", function (seq) {
44
- _this.events.fire("sequence", seq);
45
- }).on("message", function (message) {
46
- _this.events.fire("message", message);
47
- });
48
-
60
+ //Check to avoid creating unnecessary events and objects
61
+ if (this.isFirstConnection) {
62
+ this.on("reopen", function (e) {
63
+ if (_this.isConnectionUp) {
64
+ var prevConn = _this.currentConn;
65
+ _this.currentConn = e.connectionId;
66
+ _this.events.fire("reconnect", events.event("Reconnection success", {
67
+ previousConnectionId: prevConn,
68
+ currentConnectionId: _this.currentConn
69
+ }));
70
+ } else {
71
+ _this.events.fire("error", e);
72
+ }
73
+ });
74
+ this.transmitter = this.createTransmitter(socketProxy);
75
+ this.transmitter.on("sequence", function (seq) {
76
+ _this.events.fire("sequence", seq);
77
+ }).on("message", function (message) {
78
+ _this.events.fire("message", message);
79
+ });
80
+ }
49
81
  this.socket = this.openSocket(function (request) {
50
82
  _this.request = request;
51
83
  var url = request.url;
52
84
 
85
+ _this.reconnect = false;
53
86
  return {
54
87
  onMessage: function onMessage(response) {
55
88
  _this.transmitter.onMessage(response.responseBody);
@@ -58,22 +91,25 @@ var Connection = function () {
58
91
  _this.transmitter.onMessage(response.responseBody);
59
92
  },
60
93
  onOpen: function onOpen(response) {
94
+ var code = response.status;
95
+ if (code !== 200) {
96
+ _this.reconnect = false;
97
+ } else {
98
+ _this.isConnectionUp = true;
99
+ }
61
100
  var e = events.event("open", {
62
101
  url: url,
63
- code: response.status,
64
- transport: response.transport
102
+ code: code,
103
+ transport: response.transport,
104
+ connectionId: response.request.uuid
65
105
  });
66
106
  _this.log.info(e);
67
107
  _this.events.fire("open", e);
68
- },
69
- onReopen: function onReopen(response) {
70
- var e = events.event("reopen", {
71
- url: url,
72
- status: response.code,
73
- transport: response.transport
74
- });
75
- response.maxReconnectOnClose--;
76
- _this.log.info(e);
108
+ if (!_this.isFirstConnection) {
109
+ _this.maxReconnectsTotal--;
110
+ _this.events.fire("reopen", e);
111
+ }
112
+ _this.currentConn = response.request.uuid;
77
113
  },
78
114
  onTransportFailure: function onTransportFailure(reason, request) {
79
115
  var e = events.error("Transport failure", {
@@ -84,6 +120,9 @@ var Connection = function () {
84
120
  });
85
121
  _this.log.error(reason);
86
122
  _this.events.fire("error", e);
123
+ if (_this.isReconnect()) {
124
+ _this.reconnect = true;
125
+ }
87
126
  },
88
127
  onError: function onError(response) {
89
128
  var reason = response.reason || response.reasonPhrase;
@@ -106,18 +145,35 @@ var Connection = function () {
106
145
  onClose: function onClose(response) {
107
146
  var code = response.status;
108
147
  var reason = response.reason || response.reasonPhrase;
148
+ var atmosphereMessage = response.atmoMessage;
109
149
  // For whatever reason, Atmosphere sets to 408 when unsubscribing (e.g., when refreshing the page)
110
150
  if (code === 408 && response.state === "unsubscribe") {
111
151
  code = 200;
112
152
  reason = "Unsubscribed";
113
153
  }
114
-
154
+ //When 501 code is sent it could mean that the server is down, therefore do not continue trying to reconnect
155
+ if (code === 501 || code === 401 || code === 403 || code === 452) {
156
+ _this.log.warn("Unable to reconnect with code: " + code + ", reason: " + reason);
157
+ _this.reconnect = false;
158
+ }
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
+ }
115
168
  var e = events.close({
116
169
  url: url,
117
170
  transport: response.transport,
118
171
  code: code,
119
172
  reason: reason
120
173
  });
174
+ _this.isConnectionUp = false;
175
+ //Need to reset this value since it seems to be causing issues with resubscribing
176
+ response.request.uuid = 0;
121
177
  _this.log.info(e);
122
178
  _this.events.fire("close", e);
123
179
  },
@@ -126,11 +182,13 @@ var Connection = function () {
126
182
  timesExceeded: response.timesExceeded,
127
183
  maxExceeded: response.maxExceed
128
184
  });
185
+ _this.reconnect = false;
186
+ _this.log.warn("Slow connection received, Reconnection will not be attempted.");
129
187
  _this.log.info(e);
130
188
  _this.events.fire("slow", e);
131
189
  }
132
190
  };
133
- });
191
+ }, this.currentConn);
134
192
  };
135
193
 
136
194
  Connection.prototype.close = function close() {
@@ -138,6 +196,9 @@ var Connection = function () {
138
196
  try {
139
197
  this.socket.close();
140
198
  this.socket = null;
199
+ if (this.reconnect) {
200
+ this.tryReopen();
201
+ }
141
202
  } catch (err) {
142
203
  this.events.fire("error", events.error("Error closing", {
143
204
  reason: err.message,
@@ -148,6 +209,44 @@ var Connection = function () {
148
209
  }
149
210
  };
150
211
 
212
+ Connection.prototype.tryReopen = function tryReopen() {
213
+ var _this2 = this;
214
+
215
+ if (this.isConnectionUp || this.maxReconnectsTotal <= 0) {
216
+ this.log.error("Connection is already open or max reconnects was reached, won't try to reconnect");
217
+ return;
218
+ }
219
+ this.isFirstConnection = false;
220
+ var currentAttempts = this.maxReconnectAttempts;
221
+ // Recursively run this until a successful open is completed
222
+ var reconnect = function reconnect() {
223
+ if (currentAttempts <= 0) {
224
+ _this2.reconnect = false;
225
+ _this2.log.error("Error while reconnecting. No attempts left.");
226
+ //if maxattempts was reached and no connection was open, exit.
227
+ _this2.maxReconnectAttempts = 0;
228
+ return;
229
+ }
230
+ if (_this2.isConnectionUp || !_this2.reconnect) {
231
+ return;
232
+ }
233
+ _this2.log.info("Attempting reconnect. Attempts left: " + currentAttempts);
234
+ _this2.reopen(currentAttempts);
235
+ currentAttempts--;
236
+ setTimeout(reconnect, 500);
237
+ };
238
+ setTimeout(reconnect, 500);
239
+ };
240
+
241
+ Connection.prototype.reopen = function reopen(attempt) {
242
+ try {
243
+ this.open();
244
+ } catch (exception) {
245
+ this.log.warn("There was an error while reopening attempt #" + attempt);
246
+ this.events.fire("error", exception);
247
+ }
248
+ };
249
+
151
250
  Connection.prototype.send = function send(message) {
152
251
  try {
153
252
  this.transmitter.send(message);
@@ -160,6 +259,14 @@ var Connection = function () {
160
259
  }
161
260
  };
162
261
 
262
+ Connection.prototype.isReconnect = function isReconnect() {
263
+ return this.request.headers['x-Stream-isReconnect'];
264
+ };
265
+
266
+ Connection.prototype.setReconnect = function setReconnect(doReconnect) {
267
+ this.reconnect = doReconnect;
268
+ };
269
+
163
270
  Connection.prototype.setServer = function setServer(server) {
164
271
  this.request.headers['X-Stream-Instance'] = server;
165
272
  };
@@ -444,6 +551,10 @@ var Stream = function () {
444
551
  _this.pendingConnection(err);
445
552
  }
446
553
  _this.events.fire("error", err);
554
+ }).on("reconnect", function (msg) {
555
+ _this.reconnectSuccess(msg);
556
+ }).on("atmoError", function (err) {
557
+ _this.events.fire("atmoError", err);
447
558
  });
448
559
 
449
560
  this.requestid = new _UShortId2["default"]();
@@ -456,6 +567,7 @@ var Stream = function () {
456
567
  this.pendingNewsUnsubscriptions = {};
457
568
  this.pendingAlertSubscription = {};
458
569
  this.pendingTradeSubscription = {};
570
+ this.pendingTradeUnsubscription = {};
459
571
 
460
572
  this.on("error", function (err) {
461
573
  _this.log.warn(err);
@@ -473,6 +585,11 @@ var Stream = function () {
473
585
  }
474
586
  };
475
587
 
588
+ Stream.prototype.reconnectSuccess = function reconnectSuccess(msg) {
589
+ this.events.fire("reconnectSuccess", msg);
590
+ this.log.info("Successfull reconnection. Previous Id: " + msg.previousConnectionId + " Current Id = " + msg.currentConnectionId);
591
+ };
592
+
476
593
  Stream.prototype.on = function on(event, listener) {
477
594
  return this.events.on(event, listener);
478
595
  };
@@ -653,7 +770,7 @@ var Stream = function () {
653
770
  this.send(request);
654
771
  };
655
772
 
656
- Stream.prototype.subscribeTrade = function subscribeTrade(operation, optsOrCallback, callbackOrNothing) {
773
+ Stream.prototype.subscribeTrade = function subscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
657
774
  var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
658
775
  var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
659
776
 
@@ -671,11 +788,11 @@ var Stream = function () {
671
788
  mimetype: this.format,
672
789
  callback: callback,
673
790
  result: {
674
- operation: ""
791
+ notificationType: ""
675
792
  }
676
793
  };
677
794
 
678
- var request = this.buildTradeSubscribeRequest(operation, tradeSub);
795
+ var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.SUBSCRIBE);
679
796
  var id = this.requestid.next();
680
797
  tradeSub.id.push(id);
681
798
  this.pendingTradeSubscription[id] = tradeSub;
@@ -889,6 +1006,37 @@ var Stream = function () {
889
1006
  this.send(request);
890
1007
  };
891
1008
 
1009
+ Stream.prototype.unsubscribeTrade = function unsubscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
1010
+ var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
1011
+ var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
1012
+
1013
+ if (this.isClosed()) {
1014
+ var event = events.error("Stream is disconnected", {
1015
+ code: -1,
1016
+ reason: "Already disconnected"
1017
+ });
1018
+ this.events.fire("error", event);
1019
+ return;
1020
+ }
1021
+
1022
+ var tradeSub = {
1023
+ id: [],
1024
+ mimetype: this.format,
1025
+ callback: callback,
1026
+ result: {
1027
+ notificationType: ""
1028
+ }
1029
+ };
1030
+
1031
+ var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.UNSUBSCRIBE);
1032
+ var id = this.requestid.next();
1033
+ tradeSub.id.push(id);
1034
+ this.pendingTradeUnsubscription[id] = tradeSub;
1035
+ request.id = id;
1036
+
1037
+ this.send(request);
1038
+ };
1039
+
892
1040
  Stream.prototype._handlejsonmsg = function _handlejsonmsg(msg) {
893
1041
  if ((0, _streamerUtils.iscontrolmessage)(msg)) {
894
1042
  this.handlectrlmsg(msg);
@@ -969,9 +1117,10 @@ var Stream = function () {
969
1117
  return msg;
970
1118
  };
971
1119
 
972
- Stream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(operation, sub) {
1120
+ Stream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(notificationType, sub, action) {
973
1121
  var msg = new _streamerApi.messages.control.TradeSubscribeMessage();
974
- msg.operation = operation;
1122
+ msg.action = action;
1123
+ msg.notificationType = notificationType;
975
1124
  msg.mimetype = sub.mimetype;
976
1125
  return msg;
977
1126
  };
@@ -1030,6 +1179,9 @@ var Stream = function () {
1030
1179
  case _streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_RESPONSE:
1031
1180
  this.onNewsCmdFilterResponse(msg);
1032
1181
  break;
1182
+ case _streamerApi.messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE:
1183
+ this.onTradeUnsubscribeResponse(msg);
1184
+ break;
1033
1185
  case _streamerApi.messages.MessageTypeNames.ctrl.CONNECT_RESPONSE:
1034
1186
  this.onConnectResponse(msg);
1035
1187
  break;
@@ -1048,6 +1200,12 @@ var Stream = function () {
1048
1200
  case _streamerApi.messages.MessageTypeNames.ctrl.RESUBSCRIBE_MESSAGE:
1049
1201
  this.onResubscribeMessage(msg);
1050
1202
  break;
1203
+ case _streamerApi.messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE:
1204
+ this.onReconnectMessage(msg);
1205
+ break;
1206
+ case _streamerApi.messages.MessageTypeNames.ctrl.MISSED_DATA_SENT:
1207
+ this.onMissedDataSent(msg);
1208
+ break;
1051
1209
  }
1052
1210
  };
1053
1211
 
@@ -1320,9 +1478,9 @@ var Stream = function () {
1320
1478
 
1321
1479
  var result = tradeSub.result;
1322
1480
 
1323
- if (msg.operation) {
1324
- this.log.debug('Trade ' + msg.operation);
1325
- result.operation = msg.operation;
1481
+ if (msg.notificationType) {
1482
+ this.log.debug('Trade ' + msg.notificationType);
1483
+ result.notificationType = msg.notificationType;
1326
1484
  }
1327
1485
 
1328
1486
  if (tradeSub.id.length === 0) {
@@ -1381,6 +1539,41 @@ var Stream = function () {
1381
1539
  }
1382
1540
  };
1383
1541
 
1542
+ Stream.prototype.onTradeUnsubscribeResponse = function onTradeUnsubscribeResponse(msg) {
1543
+ var tradeSub = this.pendingTradeUnsubscription[msg.__id];
1544
+ var callback = tradeSub.callback;
1545
+
1546
+ (0, _utils.removeFromArray)(tradeSub.id, msg.__id);
1547
+ delete this.pendingTradeUnsubscription[msg.__id];
1548
+
1549
+ console.log(msg);
1550
+ if (msg.code != 200 && !tradeSub.failed) {
1551
+ tradeSub.failed = true;
1552
+ var event = events.error("Error unsubscribing", {
1553
+ code: msg.code,
1554
+ reason: msg.reason
1555
+ });
1556
+ this.events.fire("error", event);
1557
+ if (callback) {
1558
+ tradeSub.callback(event);
1559
+ }
1560
+ return;
1561
+ }
1562
+
1563
+ var result = tradeSub.result;
1564
+
1565
+ if (msg.notificationType) {
1566
+ this.log.debug('Trade ' + msg.notificationType);
1567
+ result.notificationType = msg.notificationType;
1568
+ }
1569
+
1570
+ if (tradeSub.id.length === 0) {
1571
+ if (callback) {
1572
+ callback(null, tradeSub.result);
1573
+ }
1574
+ }
1575
+ };
1576
+
1384
1577
  Stream.prototype.onNewsCmdFilterRefreshResponse = function onNewsCmdFilterRefreshResponse(msg) {
1385
1578
  console.log("msg", msg);
1386
1579
  if (msg.code != 200) {
@@ -1472,8 +1665,18 @@ var Stream = function () {
1472
1665
  }
1473
1666
  };
1474
1667
 
1668
+ Stream.prototype.onReconnectMessage = function onReconnectMessage(msg) {
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;
1673
+ }
1674
+ this.events.fire("reconnectMessage", msg);
1675
+ console.log(msg);
1676
+ };
1677
+
1475
1678
  Stream.prototype.onConnectResponse = function onConnectResponse(msg) {
1476
- if (msg.code != 200) {
1679
+ if (msg.code !== 200) {
1477
1680
  var event = events.error("Connection failed", {
1478
1681
  code: msg.code,
1479
1682
  reason: msg.reason
@@ -1541,6 +1744,11 @@ var Stream = function () {
1541
1744
  this.events.fire("resubscribeMessage", msg);
1542
1745
  };
1543
1746
 
1747
+ Stream.prototype.onMissedDataSent = function onMissedDataSent(msg) {
1748
+ this.log.debug(_formatting.msgfmt.fmt(msg));
1749
+ this.events.fire("missedDataSent", msg);
1750
+ };
1751
+
1544
1752
  Stream.prototype._handledatamsg = function _handledatamsg(msg) {
1545
1753
  this.events.fire("message", msg);
1546
1754
  };
@@ -1556,8 +1764,29 @@ var Stream = function () {
1556
1764
  if (!this.isClosed()) {
1557
1765
  var conn = this.conn;
1558
1766
  this.conn = null;
1559
- this.events.fire("close", msg);
1560
1767
  conn.close();
1768
+ this.events.fire("close", msg);
1769
+ if (conn.isReconnect()) {
1770
+ //Will need to reset the events since they duplicate each time it reconnects.
1771
+ this.events = new _EventSupport2["default"]();
1772
+ this.conn = conn;
1773
+ }
1774
+ }
1775
+ };
1776
+
1777
+ Stream.prototype.performReconnect = function performReconnect(callback) {
1778
+ if (this.conn != null && this.conn.isReconnect()) {
1779
+ if (this.conn.isConnectionUp) {
1780
+ this.log.warn("Connection is not closed and won't try reconnect.");
1781
+ return;
1782
+ }
1783
+ this.conn.setReconnect(true);
1784
+ this.conn.tryReopen();
1785
+ if (callback) {
1786
+ callback();
1787
+ }
1788
+ } else {
1789
+ this.log.warn("Reconnect flag is set to false");
1561
1790
  }
1562
1791
  };
1563
1792
 
@@ -1658,30 +1887,24 @@ Object.assign(Streamer, {
1658
1887
  },
1659
1888
 
1660
1889
  openStomp: function openStomp(_config, callback) {
1661
- // Note: only turn on stomp connection in Local and QA
1662
- var stompHostConfig = ["http://localhost:7000", "https://qa.quotemedia.com/cache"];
1663
- if (stompHostConfig.includes(_config.host)) {
1664
- initLogger();
1890
+ initLogger();
1665
1891
 
1666
- var credentials = void 0;
1667
- try {
1668
- credentials = (0, _AuthService.asCredentials)(_config.credentials);
1669
- } catch (e) {
1670
- callback(e);
1671
- return;
1672
- }
1892
+ var credentials = void 0;
1893
+ try {
1894
+ credentials = (0, _AuthService.asCredentials)(_config.credentials);
1895
+ } catch (e) {
1896
+ callback(e);
1897
+ return;
1898
+ }
1673
1899
 
1674
- var hostProtocol = _config.host.split('//');
1675
- var wsProtocol = hostProtocol[0] === "http:" ? "ws://" : "wss://";
1676
- var config = Object.assign({}, _config);
1677
- config.credentials = credentials;
1678
- config.format = config.format || "application/json";
1679
- config.url = wsProtocol + hostProtocol[1];
1900
+ var hostProtocol = _config.host.split('//');
1901
+ var wsProtocol = hostProtocol[0] === "http:" ? "ws://" : "wss://";
1902
+ var config = Object.assign({}, _config);
1903
+ config.credentials = credentials;
1904
+ config.format = config.format || "application/json";
1905
+ config.url = wsProtocol + hostProtocol[1];
1680
1906
 
1681
- new _StompStreamingService2["default"](_http2["default"], _stomp2["default"], logger, config).openStompStream(callback);
1682
- } else {
1683
- callback("ERROR: Stomp Connection is only turn on in Local and QA");
1684
- }
1907
+ new _StompStreamingService2["default"](_http2["default"], _stomp2["default"], logger, config).openStompStream(callback);
1685
1908
  },
1686
1909
 
1687
1910
  ping: function ping(host, callback) {
@@ -1761,6 +1984,7 @@ var StreamingService = function () {
1761
1984
  this.atmo = atmosphere;
1762
1985
  this.log = (0, _logging.asLogger)(log);
1763
1986
  this.config = config || {};
1987
+ this.maxReconnectAttempts = this.config.maxReconnectAttempts;
1764
1988
 
1765
1989
  this.format = this.config.format;
1766
1990
  if (this.config.format === 'application/json') {
@@ -1786,7 +2010,7 @@ var StreamingService = function () {
1786
2010
  }
1787
2011
  }
1788
2012
 
1789
- StreamingService.prototype.openSocket = function openSocket(handlers) {
2013
+ StreamingService.prototype.openSocket = function openSocket(handlers, connectionId) {
1790
2014
  var headers = {
1791
2015
  'X-Stream-Version': _streamerApi.VERSION,
1792
2016
  'X-Stream-Lib': _streamerApi.LIBRARY_NAME
@@ -1797,6 +2021,9 @@ var StreamingService = function () {
1797
2021
  headers['X-Stream-Conflation'] = _conflation;
1798
2022
  }
1799
2023
 
2024
+ if (connectionId != null && connectionId !== '') {
2025
+ headers['X-Stream-Previous-Connection-Id'] = connectionId;
2026
+ }
1800
2027
  var _rejectExcessiveConnection = this.config.rejectExcessiveConnection;
1801
2028
  if (_rejectExcessiveConnection != null && _rejectExcessiveConnection !== '') {
1802
2029
  headers['X-Stream-Reject'] = _rejectExcessiveConnection;
@@ -1815,6 +2042,27 @@ var StreamingService = function () {
1815
2042
  headers['X-Stream-UpdatesOnly'] = true;
1816
2043
  }
1817
2044
 
2045
+ var _isReconnect = this.config.isReconnect;
2046
+ if (_isReconnect != null && _isReconnect !== '') {
2047
+ headers['x-Stream-isReconnect'] = _isReconnect;
2048
+ }
2049
+
2050
+ var _alwaysReconnect = this.config.alwaysReconnect;
2051
+ if (_alwaysReconnect != null && _alwaysReconnect !== '') {
2052
+ headers['x-Stream-isAlwaysReopen'] = _alwaysReconnect;
2053
+ }
2054
+
2055
+ if (this.config.isMissedData === 'ALL') {
2056
+ headers['X-Stream-isReceiveAllMissedData'] = true;
2057
+ } else if (this.config.isMissedData === 'LATEST') {
2058
+ headers['X-Stream-isReceiveLatestMissedData'] = true;
2059
+ }
2060
+
2061
+ var _connectionFrom = this.config.connectionFrom;
2062
+ if (_connectionFrom != null) {
2063
+ headers['X-Stream-connectionFrom'] = _connectionFrom;
2064
+ }
2065
+
1818
2066
  Object.assign(headers, this.config.credentials.getHeaders());
1819
2067
 
1820
2068
  var request = {
@@ -1846,9 +2094,9 @@ var StreamingService = function () {
1846
2094
 
1847
2095
  return new _Connection2["default"](function (socket) {
1848
2096
  return _this2.createTransmitter(socket);
1849
- }, function (handlers) {
1850
- return _this2.openSocket(handlers);
1851
- }, this.logger);
2097
+ }, function (handlers, connectionId) {
2098
+ return _this2.openSocket(handlers, connectionId);
2099
+ }, this.log, this.maxReconnectAttempts);
1852
2100
  };
1853
2101
 
1854
2102
  StreamingService.prototype.openStream = function openStream(callback) {
@@ -3448,7 +3696,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
3448
3696
  return;
3449
3697
  }
3450
3698
 
3451
- _invokeClose(webSocketOpened);
3699
+ //Patched by Quotemedia
3700
+ _invokeClose(webSocketOpened, message);
3452
3701
 
3453
3702
  _response.state = 'closed';
3454
3703
 
@@ -4771,11 +5020,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4771
5020
  }
4772
5021
  }
4773
5022
 
4774
- function _invokeClose(wasOpen) {
5023
+ //Patched by Quotemedia
5024
+ function _invokeClose(wasOpen, message) {
4775
5025
  if (_response.state !== 'closed') {
4776
5026
  _response.state = 'closed';
4777
5027
  _response.responseBody = "";
4778
5028
  _response.messages = [];
5029
+ _response.atmoMessage = message;
4779
5030
  _response.status = !wasOpen ? 501 : 200;
4780
5031
  _invokeCallback();
4781
5032
  }
@@ -5558,6 +5809,7 @@ var EnduserAuthService = function () {
5558
5809
  this.http = http;
5559
5810
  this.host = config.host || "app.quotemedia.com";
5560
5811
  this.credentials = credentials;
5812
+ this.application = config.application;
5561
5813
  this.method = "POST";
5562
5814
  }
5563
5815
 
@@ -5566,7 +5818,7 @@ var EnduserAuthService = function () {
5566
5818
  };
5567
5819
 
5568
5820
  EnduserAuthService.prototype.login_POST = function login_POST(callback) {
5569
- var url = this.host + AUTHSERVICEURLS.authenticate_post;
5821
+ var url = this.host + AUTHSERVICEURLS.authenticate_post + (this.application ? "&application=" + this.application : "");
5570
5822
  var req = {
5571
5823
  wmId: this.credentials.wmid,
5572
5824
  username: this.credentials.username,
@@ -5666,6 +5918,9 @@ fmt.Formatter = function () {
5666
5918
  this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.NEWS_UNSUBSCRIBE_RESPONSE] = this._fmtnewsunsubscriberesponse;
5667
5919
  this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_REFRESH_RESPONSE] = this._fmtnewscmdfilterrefreshresponse;
5668
5920
  this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_RESPONSE] = this._fmtnewscmdfilterresponse;
5921
+ this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE] = this._fmttradeunsubscriberesponse;
5922
+ this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE] = this._fmtreconnectresponse;
5923
+ this.formatters[_streamerApi.messages.MessageTypeNames.ctrl.MISSED_DATA_SENT] = this._fmtmisseddatasent;
5669
5924
 
5670
5925
  //
5671
5926
  this.formatters[_streamerApi.messages.MessageTypeNames.data.QUOTE] = this._fmtquote;
@@ -5689,6 +5944,7 @@ fmt.Formatter = function () {
5689
5944
  this.formatters[_streamerApi.messages.MessageTypeNames.data.TRADENOTIFICATION] = this._fmttradeNotification;
5690
5945
  this.formatters[_streamerApi.messages.MessageTypeNames.data.NEWSCMDFILTER] = this._fmtnewscmdfilter;
5691
5946
  this.formatters[_streamerApi.messages.MessageTypeNames.data.NEWSERROR] = this._fmtnewserror;
5947
+ this.formatters[_streamerApi.messages.MessageTypeNames.data.DIVIDEND] = this._fmtdividend;
5692
5948
  };
5693
5949
 
5694
5950
  fmt.Formatter._UNKOWNTYPE = '__UNKNOWN__';
@@ -5817,6 +6073,8 @@ fmt.Formatter.prototype._fmtpricedata = function (val) {
5817
6073
  s.append(val.postMarketPercentChange);
5818
6074
  s.sep();
5819
6075
  s.append(val.lastTradeExcode);
6076
+ s.sep();
6077
+ s.append(val.currencyID);
5820
6078
  return s.toString();
5821
6079
  };
5822
6080
  fmt.Formatter.prototype._fmtlastsale = function (val) {
@@ -6321,6 +6579,33 @@ fmt.Formatter.prototype._fmtnewserror = function (val) {
6321
6579
  return s.toString();
6322
6580
  };
6323
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
+
6324
6609
  fmt.Formatter.prototype._fmtheartbeat = function (val) {
6325
6610
  var s = new fmt.StringBuilder();
6326
6611
  s.append("HEARBEAT");
@@ -6456,6 +6741,13 @@ fmt.Formatter.prototype._fmtexchangeunsubscriberesponse = function (val) {
6456
6741
  return s.toString();
6457
6742
  };
6458
6743
 
6744
+ fmt.Formatter.prototype._fmttradeunsubscriberesponse = function (val) {
6745
+ var s = new fmt.StringBuilder();
6746
+ s.append('TRADE UNSUBSCRIBED');
6747
+ // TODO
6748
+ return s.toString();
6749
+ };
6750
+
6459
6751
  fmt.Formatter.prototype._fmtconnectresponse = function (val) {
6460
6752
  var s = new fmt.StringBuilder();
6461
6753
  s.append('CONNECT');
@@ -6476,6 +6768,28 @@ fmt.Formatter.prototype._fmtconnectresponse = function (val) {
6476
6768
  return s.toString();
6477
6769
  };
6478
6770
 
6771
+ fmt.Formatter.prototype._fmtreconnectresponse = function (val) {
6772
+ var s = new fmt.StringBuilder();
6773
+ s.append('RECONNECT');
6774
+ s.sep();
6775
+ s.append(val.version);
6776
+ s.sep();
6777
+ s.append(val.flowControlCheckInterval);
6778
+ s.sep();
6779
+ s.append(val.serverInstance);
6780
+ s.sep();
6781
+ s.append(val.conflationMs);
6782
+ s.sep();
6783
+ s.append(val.rejectExcessiveConnection);
6784
+ s.sep();
6785
+ s.append(val.maxEntitlementsPerSubscription);
6786
+ s.sep();
6787
+ s.sep(val.entitlements);
6788
+ s.sep();
6789
+ s.sep(val.exchangeEntitlements);
6790
+ return s.toString();
6791
+ };
6792
+
6479
6793
  fmt.Formatter.prototype._fmtconnectionclose = function (val) {
6480
6794
  var s = new fmt.StringBuilder();
6481
6795
  s.append('CLOSE');
@@ -6565,6 +6879,20 @@ fmt.Formatter.prototype.__baseresponse = function (val, s) {
6565
6879
  s.append(val.reason);
6566
6880
  };
6567
6881
 
6882
+ fmt.Formatter.prototype._fmtmisseddatasent = function (val) {
6883
+ var s = new fmt.StringBuilder();
6884
+ s.append("MISSED DATA SENT");
6885
+ s.sep();
6886
+ s.datetime(val.timestamp);
6887
+ s.sep();
6888
+ s.append(val.requestId);
6889
+ s.sep();
6890
+ s.append(val.totalDataSent);
6891
+ s.sep();
6892
+ s.append(val.totalDataHeld);
6893
+ return s.toString();
6894
+ };
6895
+
6568
6896
  /**
6569
6897
  * Create a new sting builder.
6570
6898
  * @constructor
@@ -10242,6 +10570,7 @@ var PricedataDecoder = function () {
10242
10570
  out.postMarketChange = _Qitch2["default"].dec8double(src, offset + def.POSTMARKETCHANGE_OFFSET);
10243
10571
  out.postMarketPercentChange = this._postmarketPercentChange(out);
10244
10572
  out.lastTradeExcode = _Qitch2["default"].excode(src, offset + def.LASTTRADEEXCODE_OFFSET);
10573
+ out.currencyID = _Qitch2["default"].currencyid(src, offset + def.CURRENCYID_OFFSET);
10245
10574
 
10246
10575
  return out;
10247
10576
  };
@@ -11159,7 +11488,7 @@ var LENGTH = exports.LENGTH = SELLBLOCKTRANSACTIONS_OFFSET + _QitchConstants.INT
11159
11488
  "use strict";
11160
11489
 
11161
11490
  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;
11491
+ 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
11492
 
11164
11493
  var _QitchConstants = require("../QitchConstants");
11165
11494
 
@@ -11199,7 +11528,9 @@ var DECIMALPREMARKETVOLUME_OFFSET = exports.DECIMALPREMARKETVOLUME_OFFSET = DECI
11199
11528
  var DECIMALPOSTMARKETVOLUME_OFFSET = exports.DECIMALPOSTMARKETVOLUME_OFFSET = DECIMALPREMARKETVOLUME_OFFSET + _QitchConstants.DOUBLE_LENGTH;
11200
11529
  var DECIMALLASTTRADESIZE_OFFSET = exports.DECIMALLASTTRADESIZE_OFFSET = DECIMALPOSTMARKETVOLUME_OFFSET + _QitchConstants.DOUBLE_LENGTH;
11201
11530
 
11202
- var LENGTH = exports.LENGTH = DECIMALLASTTRADESIZE_OFFSET + _QitchConstants.DOUBLE_LENGTH;
11531
+ var CURRENCYID_OFFSET = exports.CURRENCYID_OFFSET = DECIMALLASTTRADESIZE_OFFSET + _QitchConstants.DOUBLE_LENGTH;
11532
+
11533
+ var LENGTH = exports.LENGTH = CURRENCYID_OFFSET + _QitchConstants.CURRENCYID_LENGTH;
11203
11534
 
11204
11535
  var PricedataFlags = exports.PricedataFlags = function () {
11205
11536
  function PricedataFlags() {
@@ -11415,6 +11746,10 @@ var TradeFlags = exports.TradeFlags = function () {
11415
11746
  return bits & TradeFlags.prototype.CORRECTION_MASK;
11416
11747
  };
11417
11748
 
11749
+ TradeFlags.isOutOfSequence = function isOutOfSequence(bits) {
11750
+ return bits & TradeFlags.prototype.OUTOFSEQUENCE_MASK;
11751
+ };
11752
+
11418
11753
  return TradeFlags;
11419
11754
  }();
11420
11755
 
@@ -11436,6 +11771,7 @@ TradeFlags.prototype.BLOCKTRADE_MASK = 0x00008000;
11436
11771
  TradeFlags.prototype.IGNOREOPEN_MASK = 0x00000100;
11437
11772
  TradeFlags.prototype.TRADETHROUGHEXEMPT = 0x00000200;
11438
11773
  TradeFlags.prototype.CORRECTION_MASK = 0x08000000;
11774
+ TradeFlags.prototype.OUTOFSEQUENCE_MASK = 0x00000400;
11439
11775
  }).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
11776
  },{"../QitchConstants":26,"_process":119,"buffer":109,"timers":140}],87:[function(require,module,exports){
11441
11777
  (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,setImmediate,clearImmediate,__filename,__dirname){
@@ -12192,6 +12528,10 @@ var _streamerEvents = require("../streamer-events.js");
12192
12528
 
12193
12529
  var events = _interopRequireWildcard(_streamerEvents);
12194
12530
 
12531
+ var _http = require("../http.js");
12532
+
12533
+ var _http2 = _interopRequireDefault(_http);
12534
+
12195
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; } }
12196
12536
 
12197
12537
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -12200,12 +12540,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
12200
12540
 
12201
12541
  var StompConnection = function () {
12202
12542
  function StompConnection(createTransmitter, openSocket, log) {
12543
+ var maxReconnectAttempts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 3;
12544
+ var pingUrl = arguments[4];
12545
+
12203
12546
  _classCallCheck(this, StompConnection);
12204
12547
 
12205
12548
  this.openSocket = openSocket;
12206
12549
  this.createTransmitter = createTransmitter;
12207
12550
  this.log = (0, _logging.asLogger)(log);
12208
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;
12209
12560
  }
12210
12561
 
12211
12562
  StompConnection.prototype.open = function open() {
@@ -12217,21 +12568,70 @@ var StompConnection = function () {
12217
12568
  }
12218
12569
  };
12219
12570
 
12220
- this.transmitter = this.createTransmitter(socketProxy);
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
+ });
12221
12581
 
12222
- this.transmitter.on("message", function (message) {
12223
- _this.events.fire("message", message);
12224
- });
12582
+ this.transmitter = this.createTransmitter(socketProxy);
12583
+ this.transmitter.on("message", function (message) {
12584
+ _this.events.fire("message", message);
12585
+ });
12586
+ }
12225
12587
 
12226
12588
  this.socket = this.openSocket(function (request) {
12227
12589
  _this.request = request;
12590
+ _this.reconnect = false;
12228
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
+ },
12229
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
+ }
12230
12631
  _this.transmitter.onMessage(response.body);
12231
12632
  }
12232
-
12233
12633
  };
12234
- });
12634
+ }, this.currentConn);
12235
12635
  };
12236
12636
 
12237
12637
  StompConnection.prototype.close = function close() {
@@ -12239,6 +12639,9 @@ var StompConnection = function () {
12239
12639
  try {
12240
12640
  this.socket.close();
12241
12641
  this.socket = null;
12642
+ if (this.reconnect) {
12643
+ this.tryReopen();
12644
+ }
12242
12645
  } catch (err) {
12243
12646
  this.events.fire("error", events.error("Error closing", {
12244
12647
  reason: err.message,
@@ -12249,6 +12652,44 @@ var StompConnection = function () {
12249
12652
  }
12250
12653
  };
12251
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
+
12252
12693
  StompConnection.prototype.send = function send(message) {
12253
12694
  try {
12254
12695
  this.transmitter.send(message);
@@ -12261,6 +12702,14 @@ var StompConnection = function () {
12261
12702
  }
12262
12703
  };
12263
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
+
12264
12713
  StompConnection.prototype.setServer = function setServer(server) {
12265
12714
  this.request['X-Stream-Instance'] = server;
12266
12715
  };
@@ -12269,6 +12718,21 @@ var StompConnection = function () {
12269
12718
  return this.socket == null;
12270
12719
  };
12271
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
+
12272
12736
  StompConnection.prototype.on = function on(event, callback) {
12273
12737
  return this.events.on(event, callback);
12274
12738
  };
@@ -12278,7 +12742,7 @@ var StompConnection = function () {
12278
12742
 
12279
12743
  exports["default"] = StompConnection;
12280
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")
12281
- },{"../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){
12282
12746
  (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,setImmediate,clearImmediate,__filename,__dirname){
12283
12747
  "use strict";
12284
12748
 
@@ -12339,6 +12803,8 @@ var StompStream = function () {
12339
12803
  _this.pendingConnection(err);
12340
12804
  }
12341
12805
  _this.events.fire("error", err);
12806
+ }).on("reconnect", function (msg) {
12807
+ _this.reconnectSuccess(msg);
12342
12808
  });
12343
12809
 
12344
12810
  this.requestid = new _UShortId2["default"]();
@@ -12351,6 +12817,7 @@ var StompStream = function () {
12351
12817
  this.pendingNewsUnsubscriptions = {};
12352
12818
  this.pendingAlertSubscription = {};
12353
12819
  this.pendingTradeSubscription = {};
12820
+ this.pendingTradeUnsubscription = {};
12354
12821
 
12355
12822
  this.on("error", function (err) {
12356
12823
  _this.log.warn(err);
@@ -12368,6 +12835,11 @@ var StompStream = function () {
12368
12835
  }
12369
12836
  };
12370
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
+
12371
12843
  StompStream.prototype.on = function on(event, listener) {
12372
12844
  return this.events.on(event, listener);
12373
12845
  };
@@ -12548,7 +13020,7 @@ var StompStream = function () {
12548
13020
  this.send(request);
12549
13021
  };
12550
13022
 
12551
- StompStream.prototype.subscribeTrade = function subscribeTrade(operation, optsOrCallback, callbackOrNothing) {
13023
+ StompStream.prototype.subscribeTrade = function subscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
12552
13024
  var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
12553
13025
  var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
12554
13026
 
@@ -12566,11 +13038,11 @@ var StompStream = function () {
12566
13038
  mimetype: this.format,
12567
13039
  callback: callback,
12568
13040
  result: {
12569
- operation: ""
13041
+ notificationType: ""
12570
13042
  }
12571
13043
  };
12572
13044
 
12573
- var request = this.buildTradeSubscribeRequest(operation, tradeSub);
13045
+ var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.SUBSCRIBE);
12574
13046
  var id = this.requestid.next();
12575
13047
  tradeSub.id.push(id);
12576
13048
  this.pendingTradeSubscription[id] = tradeSub;
@@ -12784,6 +13256,37 @@ var StompStream = function () {
12784
13256
  this.send(request);
12785
13257
  };
12786
13258
 
13259
+ StompStream.prototype.unsubscribeTrade = function unsubscribeTrade(notificationType, optsOrCallback, callbackOrNothing) {
13260
+ var opts = optsOrCallback && typeof optsOrCallback !== "function" ? optsOrCallback : null;
13261
+ var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
13262
+
13263
+ if (this.isClosed()) {
13264
+ var event = events.error("Stream is disconnected", {
13265
+ code: -1,
13266
+ reason: "Already disconnected"
13267
+ });
13268
+ this.events.fire("error", event);
13269
+ return;
13270
+ }
13271
+
13272
+ var tradeSub = {
13273
+ id: [],
13274
+ mimetype: this.format,
13275
+ callback: callback,
13276
+ result: {
13277
+ notificationType: ""
13278
+ }
13279
+ };
13280
+
13281
+ var request = this.buildTradeSubscribeRequest(notificationType, tradeSub, _streamerApi.messages.control.Action.UNSUBSCRIBE);
13282
+ var id = this.requestid.next();
13283
+ tradeSub.id.push(id);
13284
+ this.pendingTradeUnsubscription[id] = tradeSub;
13285
+ request.id = id;
13286
+
13287
+ this.send(request);
13288
+ };
13289
+
12787
13290
  StompStream.prototype._handlejsonmsg = function _handlejsonmsg(msg) {
12788
13291
  if ((0, _streamerUtils.iscontrolmessage)(msg)) {
12789
13292
  this.handlectrlmsg(msg);
@@ -12864,9 +13367,10 @@ var StompStream = function () {
12864
13367
  return msg;
12865
13368
  };
12866
13369
 
12867
- StompStream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(operation, sub) {
13370
+ StompStream.prototype.buildTradeSubscribeRequest = function buildTradeSubscribeRequest(notificationType, sub, action) {
12868
13371
  var msg = new _streamerApi.messages.control.TradeSubscribeMessage();
12869
- msg.operation = operation;
13372
+ msg.action = action;
13373
+ msg.notificationType = notificationType;
12870
13374
  msg.mimetype = sub.mimetype;
12871
13375
  return msg;
12872
13376
  };
@@ -12925,6 +13429,9 @@ var StompStream = function () {
12925
13429
  case _streamerApi.messages.MessageTypeNames.ctrl.NEWS_CMD_FILTER_RESPONSE:
12926
13430
  this.onNewsCmdFilterResponse(msg);
12927
13431
  break;
13432
+ case _streamerApi.messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE:
13433
+ this.onTradeUnsubscribeResponse(msg);
13434
+ break;
12928
13435
  case _streamerApi.messages.MessageTypeNames.ctrl.CONNECT_RESPONSE:
12929
13436
  this.onConnectResponse(msg);
12930
13437
  break;
@@ -12946,6 +13453,12 @@ var StompStream = function () {
12946
13453
  case _streamerApi.messages.MessageTypeNames.ctrl.OPEN_FLOW:
12947
13454
  this.onOpenFlow(msg);
12948
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;
12949
13462
  }
12950
13463
  };
12951
13464
 
@@ -13218,9 +13731,9 @@ var StompStream = function () {
13218
13731
 
13219
13732
  var result = tradeSub.result;
13220
13733
 
13221
- if (msg.operation) {
13222
- this.log.debug('Trade ' + msg.operation);
13223
- result.operation = msg.operation;
13734
+ if (msg.notificationType) {
13735
+ this.log.debug('Trade ' + msg.notificationType);
13736
+ result.notificationType = msg.notificationType;
13224
13737
  }
13225
13738
 
13226
13739
  if (tradeSub.id.length === 0) {
@@ -13279,6 +13792,41 @@ var StompStream = function () {
13279
13792
  }
13280
13793
  };
13281
13794
 
13795
+ StompStream.prototype.onTradeUnsubscribeResponse = function onTradeUnsubscribeResponse(msg) {
13796
+ var tradeSub = this.pendingTradeUnsubscription[msg.__id];
13797
+ var callback = tradeSub.callback;
13798
+
13799
+ (0, _utils.removeFromArray)(tradeSub.id, msg.__id);
13800
+ delete this.pendingTradeUnsubscription[msg.__id];
13801
+
13802
+ console.log(msg);
13803
+ if (msg.code != 200 && !tradeSub.failed) {
13804
+ tradeSub.failed = true;
13805
+ var event = events.error("Error unsubscribing", {
13806
+ code: msg.code,
13807
+ reason: msg.reason
13808
+ });
13809
+ this.events.fire("error", event);
13810
+ if (callback) {
13811
+ tradeSub.callback(event);
13812
+ }
13813
+ return;
13814
+ }
13815
+
13816
+ var result = tradeSub.result;
13817
+
13818
+ if (msg.notificationType) {
13819
+ this.log.debug('Trade ' + msg.notificationType);
13820
+ result.notificationType = msg.notificationType;
13821
+ }
13822
+
13823
+ if (tradeSub.id.length === 0) {
13824
+ if (callback) {
13825
+ callback(null, tradeSub.result);
13826
+ }
13827
+ }
13828
+ };
13829
+
13282
13830
  StompStream.prototype.onNewsCmdFilterRefreshResponse = function onNewsCmdFilterRefreshResponse(msg) {
13283
13831
  console.log("msg", msg);
13284
13832
  if (msg.code != 200) {
@@ -13370,8 +13918,18 @@ var StompStream = function () {
13370
13918
  }
13371
13919
  };
13372
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
+
13373
13931
  StompStream.prototype.onConnectResponse = function onConnectResponse(msg) {
13374
- if (msg.code != 200) {
13932
+ if (msg.code !== 200) {
13375
13933
  var event = events.error("Connection failed", {
13376
13934
  code: msg.code,
13377
13935
  reason: msg.reason
@@ -13438,6 +13996,11 @@ var StompStream = function () {
13438
13996
  this.events.fire("resubscribeMessage", msg);
13439
13997
  };
13440
13998
 
13999
+ StompStream.prototype.onMissedDataSent = function onMissedDataSent(msg) {
14000
+ this.log.debug(_formatting.msgfmt.fmt(msg));
14001
+ this.events.fire("missedDataSent", msg);
14002
+ };
14003
+
13441
14004
  StompStream.prototype.onOpenFlow = function onOpenFlow(msg) {
13442
14005
  this.conn.send(msg);
13443
14006
  };
@@ -13456,8 +14019,29 @@ var StompStream = function () {
13456
14019
  if (!this.isClosed()) {
13457
14020
  var conn = this.conn;
13458
14021
  this.conn = null;
13459
- this.events.fire("close", msg);
13460
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");
13461
14045
  }
13462
14046
  };
13463
14047
 
@@ -13516,6 +14100,8 @@ var STREAMURLS = {
13516
14100
  "streamStomp": "/stream/connect"
13517
14101
  };
13518
14102
 
14103
+ var HEADERPARAMS = '';
14104
+
13519
14105
  var StompStreamingService = function () {
13520
14106
  function StompStreamingService(http, stompJs, log, config) {
13521
14107
  var _this = this;
@@ -13526,6 +14112,7 @@ var StompStreamingService = function () {
13526
14112
  this.stompJs = stompJs;
13527
14113
  this.log = (0, _logging.asLogger)(log);
13528
14114
  this.config = config || {};
14115
+ this.maxReconnectAttempts = this.config.maxReconnectAttempts;
13529
14116
 
13530
14117
  this.format = this.config.format;
13531
14118
  if (this.config.format === 'application/json') {
@@ -13535,33 +14122,65 @@ var StompStreamingService = function () {
13535
14122
  }
13536
14123
  }
13537
14124
 
13538
- StompStreamingService.prototype.openStompSocket = function openStompSocket(handlers) {
14125
+ StompStreamingService.prototype.openStompSocket = function openStompSocket(handlers, connectionId) {
14126
+ HEADERPARAMS = '';
13539
14127
  var headers = {
13540
14128
  'X-Stream-Version': _streamerApi.VERSION,
13541
14129
  'X-Stream-Lib': _streamerApi.LIBRARY_NAME
13542
14130
  };
14131
+ this.addToHeaderParams('X-Stream-Version', _streamerApi.VERSION);
14132
+ this.addToHeaderParams('X-Stream-Lib', _streamerApi.LIBRARY_NAME);
13543
14133
 
13544
14134
  var _conflation = this.config.conflation;
13545
14135
  if (_conflation != null && _conflation !== '') {
13546
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);
13547
14143
  }
13548
14144
 
13549
14145
  var _rejectExcessiveConnection = this.config.rejectExcessiveConnection;
13550
14146
  if (_rejectExcessiveConnection != null && _rejectExcessiveConnection !== '') {
13551
14147
  headers['X-Stream-Reject'] = _rejectExcessiveConnection;
14148
+ this.addToHeaderParams('X-Stream-Reject', _rejectExcessiveConnection);
13552
14149
  }
13553
14150
 
13554
14151
  if (this.config.format === 'application/json' || this.config.format === _message.MimeTypes.QITCH) {
13555
14152
  headers['X-Stream-Format'] = this.format;
14153
+ this.addToHeaderParams('X-Stream-Format', this.format);
13556
14154
  }
13557
14155
 
13558
14156
  if (this.config.updatesOnly === 'true') {
13559
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);
13560
14179
  }
13561
14180
 
13562
14181
  Object.assign(headers, this.config.credentials.getHeaders());
13563
14182
 
13564
- var url = this.config.url + STREAMURLS.streamStomp;
14183
+ var url = this.config.url + STREAMURLS.streamStomp + HEADERPARAMS;
13565
14184
  var stompClient = this.stompJs.Stomp.client(url);
13566
14185
 
13567
14186
  var authMessage = new _streamerApi.messages.control.AuthenticationMessage();
@@ -13570,6 +14189,7 @@ var StompStreamingService = function () {
13570
14189
  authMessage.authorization = this.config.credentials.sid;
13571
14190
  } else if (this.config.credentials.wmid !== undefined && this.config.credentials.token !== undefined) {
13572
14191
  authMessage.authenticationMethod = "enterprise";
14192
+ authMessage.wmid = this.config.credentials.wmid;
13573
14193
  authMessage.authorization = this.config.credentials.token;
13574
14194
  } else if (this.config.credentials.wmid !== undefined) {
13575
14195
  authMessage.authenticationMethod = "wmid";
@@ -13587,20 +14207,25 @@ var StompStreamingService = function () {
13587
14207
  authMessage.rejectExcessiveConnection = this.config.rejectExcessiveConnection;
13588
14208
  }
13589
14209
 
13590
- stompClient.connect({}, function (frame) {
14210
+ stompClient.connect(headers, function (frame) {
13591
14211
  stompClient.subscribe('/user/queue/messages', function (responseMessage) {
13592
14212
  handlers(headers).onMessage(responseMessage);
13593
14213
  });
13594
14214
 
13595
- stompClient.send("/stream/subscribe", headers, JSON.stringify(authMessage));
14215
+ handlers(headers).onOpen(frame);
14216
+ stompClient.send("/stream/message", headers, JSON.stringify(authMessage));
14217
+ }, function (frame) {
14218
+ handlers(headers).onError(frame);
13596
14219
  });
13597
14220
 
13598
14221
  return {
13599
14222
  send: function send(msg) {
13600
- stompClient.send("/stream/subscribe", headers, msg);
14223
+ stompClient.send("/stream/message", headers, msg);
13601
14224
  },
13602
14225
  close: function close() {
13603
- stompClient.disconnect();
14226
+ stompClient.disconnect(function () {
14227
+ handlers(headers).onClose();
14228
+ });
13604
14229
  }
13605
14230
  };
13606
14231
  };
@@ -13610,9 +14235,9 @@ var StompStreamingService = function () {
13610
14235
 
13611
14236
  return new _StompConnection2["default"](function (socket) {
13612
14237
  return _this2.createTransmitter(socket);
13613
- }, function (handlers) {
13614
- return _this2.openStompSocket(handlers);
13615
- }, this.logger);
14238
+ }, function (handlers, connectionId) {
14239
+ return _this2.openStompSocket(handlers, connectionId);
14240
+ }, this.log, this.maxReconnectAttempts, this.config.host + STREAMURLS.ping);
13616
14241
  };
13617
14242
 
13618
14243
  StompStreamingService.prototype.openStompStream = function openStompStream(callback) {
@@ -13642,6 +14267,14 @@ var StompStreamingService = function () {
13642
14267
  });
13643
14268
  };
13644
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
+
13645
14278
  return StompStreamingService;
13646
14279
  }();
13647
14280
 
@@ -13660,7 +14293,7 @@ exports.__esModule = true;
13660
14293
  */
13661
14294
 
13662
14295
  var LIBRARY_NAME = exports.LIBRARY_NAME = "JavaScript";
13663
- var VERSION = exports.VERSION = "2.27.0";
14296
+ var VERSION = exports.VERSION = "2.33.0";
13664
14297
 
13665
14298
  /**
13666
14299
  * Streamer message api namespace.
@@ -13724,7 +14357,10 @@ messages.MessageTypeNames = {
13724
14357
  NEWS_CMD_FILTER_REFRESH_RESPONSE: 'C25',
13725
14358
  NEWS_CMD_FILTER_RESPONSE: 'C26',
13726
14359
  AUTHENTICATION: 'C27',
13727
- OPEN_FLOW: 'C28'
14360
+ OPEN_FLOW: 'C28',
14361
+ RECONNECT_RESPONSE: 'C29',
14362
+ TRADE_UNSUBSCRIBE_RESPONSE: 'C30',
14363
+ MISSED_DATA_SENT: 'C31'
13728
14364
  },
13729
14365
  /**
13730
14366
  * Name space for data message type identifiers.<br>
@@ -13752,7 +14388,8 @@ messages.MessageTypeNames = {
13752
14388
  NEWS: 'D18',
13753
14389
  TRADENOTIFICATION: 'D19',
13754
14390
  NEWSCMDFILTER: 'D20',
13755
- NEWSERROR: 'D21'
14391
+ NEWSERROR: 'D21',
14392
+ DIVIDEND: 'D22'
13756
14393
  }
13757
14394
  };
13758
14395
 
@@ -13960,11 +14597,18 @@ messages.control.AlertsSubUnsubMessage.prototype = new messages.control.CtrlMess
13960
14597
  messages.control.TradeSubscribeMessage = function () {
13961
14598
  this.init(messages.MessageTypeNames.ctrl.TRADE_SUBSCRIBE);
13962
14599
 
14600
+ /**
14601
+ * The action the server will taken when receiving this message.
14602
+ * @type {string}
14603
+ * @see exports.messages.control.Action
14604
+ */
14605
+ this.action = null;
14606
+
13963
14607
  /**
13964
14608
  * The subscribe/un-subscribe for trade notifications.
13965
14609
  * @type {Array.<string>}
13966
14610
  */
13967
- this.operation = null;
14611
+ this.notificationType = null;
13968
14612
 
13969
14613
  /**
13970
14614
  * Requested message mime-type format.
@@ -14083,6 +14727,15 @@ messages.control.NewsUnsubscribeResponse = function () {
14083
14727
  };
14084
14728
  messages.control.NewsUnsubscribeResponse.prototype = new messages.control.BaseResponse();
14085
14729
 
14730
+ /**
14731
+ * Creates Trade notification subscribe response message.
14732
+ * @constructor
14733
+ */
14734
+ messages.control.TradeUnsubscribeResponse = function () {
14735
+ this.init(messages.MessageTypeNames.ctrl.TRADE_UNSUBSCRIBE_RESPONSE);
14736
+ };
14737
+
14738
+ messages.control.TradeUnsubscribeResponse.prototype = new messages.control.BaseResponse();
14086
14739
  /**
14087
14740
  * Creates a stream entitlement info.
14088
14741
  * @constructor
@@ -14142,6 +14795,44 @@ messages.control.ConnectResponse = function () {
14142
14795
  };
14143
14796
  messages.control.ConnectResponse.prototype = new messages.control.BaseResponse();
14144
14797
 
14798
+ /**
14799
+ * Creates a new reconnect response message
14800
+ * @constructor
14801
+ */
14802
+ messages.control.ReconnectResponse = function () {
14803
+ undefined.init(messages.MessageTypeNames.ctrl.RECONNECT_RESPONSE);
14804
+
14805
+ /**
14806
+ * The server version.
14807
+ * @type {string}
14808
+ */
14809
+ undefined.version = null;
14810
+
14811
+ /**
14812
+ * The flow control check interval.
14813
+ * @type {number}
14814
+ */
14815
+ undefined.flowControlCheckInterval = null;
14816
+
14817
+ /**
14818
+ * The server instance connected to.
14819
+ * @type {string}
14820
+ */
14821
+ undefined.serverInstance = null;
14822
+
14823
+ /**
14824
+ * The conflation rate in milliseconds.
14825
+ * @type {number}
14826
+ */
14827
+ undefined.conflationMs = null;
14828
+
14829
+ /**
14830
+ * The previous subscriptions
14831
+ * @type {Array.<messages.control.StreamEntitlement>}
14832
+ */
14833
+ undefined.previousSubscriptions = null;
14834
+ };
14835
+
14145
14836
  /**
14146
14837
  * Creates a connection response message.
14147
14838
  * @constructor
@@ -14215,6 +14906,12 @@ messages.control.AuthenticationMessage = function () {
14215
14906
  */
14216
14907
  this.authenticationMethod = null;
14217
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
+
14218
14915
  /**
14219
14916
  * Auth token.
14220
14917
  * @type {String}
@@ -14317,6 +15014,22 @@ messages.control.ResubscribeMessage = function () {
14317
15014
  };
14318
15015
  messages.control.ResubscribeMessage.prototype = new messages.control.CtrlMessage();
14319
15016
 
15017
+ /**
15018
+ * Creates a Missed Data Sent response message.
15019
+ * @constructor
15020
+ */
15021
+ messages.control.MissedDataSent = function () {
15022
+ this.init(messages.MessageTypeNames.ctrl.MISSED_DATA_SENT);
15023
+
15024
+ /**
15025
+ * The timestamp of message creation.
15026
+ * @type {number|JSBI} for connections with JSON format timestamp will be decoded as number,
15027
+ * for connections with QITCH format - {@link JSBI.BigInt}
15028
+ */
15029
+ this.timestamp = null;
15030
+ };
15031
+ messages.control.MissedDataSent.prototype = new messages.control.CtrlMessage();
15032
+
14320
15033
  /**
14321
15034
  * Stream entitlement types.
14322
15035
  * @enum