@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
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@ Javascript library responsible to connect to the Quotemedia Streaming Service.
|
|
|
9
9
|
````
|
|
10
10
|
|
|
11
11
|
### Usage
|
|
12
|
-
Include the javascript file (qmci-streamer-2.
|
|
12
|
+
Include the javascript file (qmci-streamer-2.31.0.min.js) in your html page.
|
|
13
13
|
|
|
14
14
|
````
|
|
15
|
-
<script src="qmci-streamer-2.
|
|
15
|
+
<script src="qmci-streamer-2.31.0.min.js"></script>
|
|
16
16
|
````
|
|
17
17
|
|
|
18
18
|
After this, you should be able to use the Streamer object. It will allow you to authenticate, subscribe and unsubscribe
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
|
|
3
3
|
<head>
|
|
4
|
-
<script src="qmci-streamer-2.
|
|
4
|
+
<script src="qmci-streamer-2.31.0.min.js"></script>
|
|
5
5
|
</head>
|
|
6
6
|
|
|
7
7
|
<body>
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
}));
|
|
136
136
|
|
|
137
137
|
|
|
138
|
+
|
|
138
139
|
/**
|
|
139
140
|
* Subscription to an exchange to receive stock status messages containing data such as halt,
|
|
140
141
|
* resume, regSHO.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
|
|
3
3
|
<head>
|
|
4
|
-
<script src="qmci-streamer-2.
|
|
4
|
+
<script src="qmci-streamer-2.31.0.min.js"></script>
|
|
5
5
|
</head>
|
|
6
6
|
|
|
7
7
|
<body>
|
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
117
|
|
|
118
|
+
|
|
118
119
|
/**
|
|
119
120
|
* Subscription to an exchange to receive stock status messages containing data such as halt,
|
|
120
121
|
* resume, regSHO.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
|
|
3
3
|
<head>
|
|
4
|
-
<script src="qmci-streamer-2.
|
|
4
|
+
<script src="qmci-streamer-2.31.0.min.js"></script>
|
|
5
5
|
</head>
|
|
6
6
|
|
|
7
7
|
<body>
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
// Log in to get an SID.
|
|
30
30
|
// This can be done by directly calling to QuoteMedia's auth service.
|
|
31
31
|
Streamer.login({
|
|
32
|
-
host: 'https://
|
|
32
|
+
host: 'https://app.quotemedia.com/auth',
|
|
33
33
|
credentials: {
|
|
34
|
-
wmid: "
|
|
35
|
-
username: "
|
|
36
|
-
password: "
|
|
34
|
+
wmid: "YourWebmasterID",
|
|
35
|
+
username: "YourUsername",
|
|
36
|
+
password: "YourPassword"
|
|
37
37
|
}
|
|
38
38
|
}, then(function(sid) {
|
|
39
39
|
// After obtaining the SID, use it to authenticate
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
// Must be set before calling open(). NOTE: May cause performance degradation.
|
|
51
51
|
// Streamer.logger = console;
|
|
52
52
|
Streamer.open({
|
|
53
|
-
host: '
|
|
53
|
+
host: 'https://app.quotemedia.com/cache',
|
|
54
54
|
cors: true,
|
|
55
55
|
rejectExcessiveConnection: false,
|
|
56
56
|
conflation: null,
|
|
@@ -102,9 +102,6 @@
|
|
|
102
102
|
}
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
.on("reconnectMessage", (msg) => {
|
|
106
|
-
print(JSON.stringify(msg.entitlements), "blue");
|
|
107
|
-
})
|
|
108
105
|
// It's recommended to attach an error handler
|
|
109
106
|
// to help diagnose unexpected errors.
|
|
110
107
|
.on("error", function(err) {
|
|
@@ -125,6 +122,18 @@
|
|
|
125
122
|
.on("resubscribeMessage", function(msg) {
|
|
126
123
|
print("Resubscription has been triggered. Timestamp: " + msg.timestamp);
|
|
127
124
|
})
|
|
125
|
+
//When reconnecting, you will need to listen to the main reconnect events. They will be in the following order:
|
|
126
|
+
// -reconnectSuccess: connection was successfully re-establish. reconnectSucess contains previousconnectionId and CurrentconnectionId.
|
|
127
|
+
// You should receive this along with a 200 ConnnectResponse.
|
|
128
|
+
// -reconnectMessage: once connection was estabished, if there where any previous subscriptions, you will recieve a
|
|
129
|
+
// reconnectMessage with the status code and symbols resubscribed
|
|
130
|
+
// -missedDatamessage: TODO
|
|
131
|
+
.on("reconnectSuccess", (msg) => {
|
|
132
|
+
print(`${msg.previousConnectionId} -> ${msg.currentConnectionId}`)
|
|
133
|
+
})
|
|
134
|
+
.on("reconnectMessage", (msg) => {
|
|
135
|
+
print(JSON.stringify(msg.entitlements), "blue");
|
|
136
|
+
})
|
|
128
137
|
// Due to network hiccups or other unexepected errors,
|
|
129
138
|
// the stream may be unexpectedly closed.
|
|
130
139
|
// For robustness, it's recommended to add reconnection logic.
|
|
@@ -178,12 +187,35 @@
|
|
|
178
187
|
stream.getSessionStats();
|
|
179
188
|
|
|
180
189
|
setTimeout(function() {
|
|
181
|
-
|
|
182
|
-
|
|
190
|
+
|
|
191
|
+
stream.unsubscribe(["MSFT"], [Streamer.dataTypes.TRADE], {}, then(function(result) {
|
|
192
|
+
|
|
193
|
+
var unsubscribed = result.unsubscribed;
|
|
194
|
+
for (var i = 0; i < unsubscribed.length; ++i) {
|
|
195
|
+
print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
|
|
196
|
+
}
|
|
197
|
+
// Finally, close the stream.
|
|
198
|
+
stream.close(then(function() {
|
|
199
|
+
print("Streamer connection closed", "red");
|
|
200
|
+
}));
|
|
183
201
|
}));
|
|
184
202
|
}, 5000);
|
|
185
203
|
}));
|
|
186
204
|
|
|
205
|
+
//Now one thing to notice when using reconnect is that you can implement your own reconnect logic in the case
|
|
206
|
+
//that you close your connection for an other reason like slow, errors, etc.
|
|
207
|
+
//For this you will need to first close the previous conection and then call the performReconnect method as follows
|
|
208
|
+
//Also your reconnections do have a limit after closing this is set to 3 maxAttempts, once this is reached, any type of reconnections will stop.
|
|
209
|
+
|
|
210
|
+
//NOTICE: Transport errors are ALREADY HANDLED by default no need of doing these extra steps, since the call will fail due to connection
|
|
211
|
+
//already being up
|
|
212
|
+
|
|
213
|
+
// Stream already closed above
|
|
214
|
+
//stream.close();
|
|
215
|
+
stream.performReconnect(then(() => {
|
|
216
|
+
print("Successfull reconnection", "red")
|
|
217
|
+
}));
|
|
218
|
+
|
|
187
219
|
/**
|
|
188
220
|
* Subscription to an exchange to receive stock status messages containing data such as halt,
|
|
189
221
|
* resume, regSHO.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
|
|
3
3
|
<head>
|
|
4
|
-
<script src="qmci-streamer-2.
|
|
4
|
+
<script src="qmci-streamer-2.31.0.min.js"></script>
|
|
5
5
|
</head>
|
|
6
6
|
|
|
7
7
|
<body>
|
|
@@ -189,6 +189,7 @@
|
|
|
189
189
|
}, 5000);
|
|
190
190
|
}));
|
|
191
191
|
|
|
192
|
+
|
|
192
193
|
/**
|
|
193
194
|
* Subscription to an exchange to receive stock status messages containing data such as halt,
|
|
194
195
|
* resume, regSHO.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
|
|
3
3
|
<head>
|
|
4
|
-
<script src="qmci-streamer-2.
|
|
4
|
+
<script src="qmci-streamer-2.31.0.min.js"></script>
|
|
5
5
|
</head>
|
|
6
6
|
|
|
7
7
|
<body>
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
}));
|
|
115
115
|
|
|
116
116
|
|
|
117
|
+
|
|
117
118
|
/**
|
|
118
119
|
* Subscription to an exchange to receive stock status messages containing data such as halt,
|
|
119
120
|
* resume, regSHO.
|