@ariva-mds/mds 2.11.0 → 2.13.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/lib/cjs/index.js
CHANGED
|
@@ -33,10 +33,16 @@ class MdsConnectionState {
|
|
|
33
33
|
this.isConnected = false;
|
|
34
34
|
this.isAuthenticated = false;
|
|
35
35
|
}
|
|
36
|
+
authenticationAccepted() {
|
|
37
|
+
this.isAuthenticated = true;
|
|
38
|
+
}
|
|
39
|
+
authenticationEnded() {
|
|
40
|
+
this.isAuthenticated = false;
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
exports.MdsConnectionState = MdsConnectionState;
|
|
38
44
|
class MdsConnection {
|
|
39
|
-
constructor(websocketUrl, authdataCallback, options = {}) {
|
|
45
|
+
constructor(websocketUrl, authdataCallback, options = { debug: false }) {
|
|
40
46
|
this.state = new MdsConnectionState();
|
|
41
47
|
this.waitingForAuthentification = [];
|
|
42
48
|
this.counter = 0;
|
|
@@ -44,8 +50,10 @@ class MdsConnection {
|
|
|
44
50
|
this.runningRequestsPromise = new Map();
|
|
45
51
|
this.runningRequestsParameters = new Map();
|
|
46
52
|
this.replayRequestsOnOpen = new Map();
|
|
53
|
+
this.isDebug = false;
|
|
47
54
|
this.authdataCallback = authdataCallback;
|
|
48
55
|
this.websocketUrl = websocketUrl;
|
|
56
|
+
this.isDebug = options.debug ? true : false;
|
|
49
57
|
this.websocket = new reconnecting_websocket_1.default(this.websocketUrl, [], options.wsOptions);
|
|
50
58
|
this.stayAuthenticated();
|
|
51
59
|
const outer = this;
|
|
@@ -64,7 +72,7 @@ class MdsConnection {
|
|
|
64
72
|
this.websocket.onclose = function () {
|
|
65
73
|
outer.state.connectionClosed();
|
|
66
74
|
outer.replayRequestsOnOpen = new Map(outer.runningRequestsParameters);
|
|
67
|
-
|
|
75
|
+
outer.debug("close");
|
|
68
76
|
};
|
|
69
77
|
this.websocket.onmessage = function (e) {
|
|
70
78
|
outer.processWebsocketMessageEvent(e);
|
|
@@ -124,22 +132,27 @@ class MdsConnection {
|
|
|
124
132
|
new rxjs_1.Observable((subscriber) => {
|
|
125
133
|
this.authdataCallback().then((mdsAuthdata) => outer.observable({ 'subscribeAuthentication': mdsAuthdata }, true)).then((observable) => observable.subscribe({
|
|
126
134
|
next(x) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
outer.
|
|
135
|
+
if (x.dataAuthentication.secondsToLive > 30) {
|
|
136
|
+
subscriber.next(x);
|
|
137
|
+
for (const json of outer.waitingForAuthentification) {
|
|
138
|
+
outer.websocket.send(JSON.stringify(json));
|
|
139
|
+
}
|
|
140
|
+
outer.waitingForAuthentification = [];
|
|
141
|
+
outer.state.authenticationAccepted();
|
|
130
142
|
}
|
|
131
|
-
outer.waitingForAuthentification = [];
|
|
132
143
|
},
|
|
133
144
|
complete() {
|
|
145
|
+
outer.state.authenticationEnded();
|
|
134
146
|
subscriber.complete();
|
|
135
147
|
},
|
|
136
148
|
error() {
|
|
149
|
+
outer.state.authenticationEnded();
|
|
137
150
|
subscriber.complete();
|
|
138
151
|
}
|
|
139
152
|
}));
|
|
140
153
|
})
|
|
141
154
|
.pipe((0, rxjs_1.repeat)({ delay: 2000 }))
|
|
142
|
-
.subscribe((c) =>
|
|
155
|
+
.subscribe((c) => outer.debug("auth outer " + c));
|
|
143
156
|
}
|
|
144
157
|
generateNextRequestId() {
|
|
145
158
|
return "request-" + this.counter++;
|
|
@@ -178,7 +191,7 @@ class MdsConnection {
|
|
|
178
191
|
}
|
|
179
192
|
processWebsocketMessageEvent(e) {
|
|
180
193
|
const msg = JSON.parse(e.data);
|
|
181
|
-
|
|
194
|
+
this.debug("we received " + JSON.stringify(msg));
|
|
182
195
|
const promise = this.runningRequestsPromise.get(msg.requestId);
|
|
183
196
|
const subscriber = this.runningRequestsObservable.get(msg.requestId);
|
|
184
197
|
if (promise) {
|
|
@@ -214,5 +227,9 @@ class MdsConnection {
|
|
|
214
227
|
}
|
|
215
228
|
}
|
|
216
229
|
}
|
|
230
|
+
debug(s) {
|
|
231
|
+
if (this.isDebug)
|
|
232
|
+
console.log(s);
|
|
233
|
+
}
|
|
217
234
|
}
|
|
218
235
|
exports.MdsConnection = MdsConnection;
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -15,8 +15,11 @@ export declare class MdsConnectionState {
|
|
|
15
15
|
isAuthenticated: boolean;
|
|
16
16
|
connectionOpened(): void;
|
|
17
17
|
connectionClosed(): void;
|
|
18
|
+
authenticationAccepted(): void;
|
|
19
|
+
authenticationEnded(): void;
|
|
18
20
|
}
|
|
19
21
|
export type Options = {
|
|
22
|
+
debug?: boolean;
|
|
20
23
|
wsOptions?: ReconnectingWebSocketOptions;
|
|
21
24
|
};
|
|
22
25
|
export declare class MdsConnection {
|
|
@@ -30,6 +33,7 @@ export declare class MdsConnection {
|
|
|
30
33
|
private readonly runningRequestsParameters;
|
|
31
34
|
private replayRequestsOnOpen;
|
|
32
35
|
private readonly authdataCallback;
|
|
36
|
+
private isDebug;
|
|
33
37
|
constructor(websocketUrl: string, authdataCallback: () => Promise<MdsAuthdata>, options?: Options);
|
|
34
38
|
heartbeat(): Observable<String>;
|
|
35
39
|
marketstates(marketstateQueries: String[]): Observable<MarketstateUpdate>;
|
|
@@ -42,5 +46,6 @@ export declare class MdsConnection {
|
|
|
42
46
|
private observable;
|
|
43
47
|
private promise;
|
|
44
48
|
private processWebsocketMessageEvent;
|
|
49
|
+
private debug;
|
|
45
50
|
}
|
|
46
51
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAqB,MAAM,MAAM,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAC,iBAAiB,EAAqD,MAAM,4BAA4B,CAAA;AAGhH,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,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAA2C;IACrF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA+B;IACtE,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAA+B;IACzE,OAAO,CAAC,oBAAoB,CAA+B;IAE3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;IAC9D,OAAO,CAAC,OAAO,CAAkB;gBAErB,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,GAAE,OAA0B;IAmC5G,SAAS,IAAI,UAAU,CAAC,MAAM,CAAC;IAK/B,YAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC;IA4BzE,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAK/E,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAM/E,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjD,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,iBAAiB;IAsCzB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,UAAU;IA4BlB,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,4BAA4B;IAkCpC,OAAO,CAAC,KAAK;CAKhB"}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -26,6 +26,12 @@ export class MdsConnectionState {
|
|
|
26
26
|
this.isConnected = false;
|
|
27
27
|
this.isAuthenticated = false;
|
|
28
28
|
}
|
|
29
|
+
authenticationAccepted() {
|
|
30
|
+
this.isAuthenticated = true;
|
|
31
|
+
}
|
|
32
|
+
authenticationEnded() {
|
|
33
|
+
this.isAuthenticated = false;
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
export class MdsConnection {
|
|
31
37
|
websocketUrl;
|
|
@@ -38,9 +44,11 @@ export class MdsConnection {
|
|
|
38
44
|
runningRequestsParameters = new Map();
|
|
39
45
|
replayRequestsOnOpen = new Map();
|
|
40
46
|
authdataCallback;
|
|
41
|
-
|
|
47
|
+
isDebug = false;
|
|
48
|
+
constructor(websocketUrl, authdataCallback, options = { debug: false }) {
|
|
42
49
|
this.authdataCallback = authdataCallback;
|
|
43
50
|
this.websocketUrl = websocketUrl;
|
|
51
|
+
this.isDebug = options.debug ? true : false;
|
|
44
52
|
this.websocket = new ReconnectingWebSocket(this.websocketUrl, [], options.wsOptions);
|
|
45
53
|
this.stayAuthenticated();
|
|
46
54
|
const outer = this;
|
|
@@ -59,7 +67,7 @@ export class MdsConnection {
|
|
|
59
67
|
this.websocket.onclose = function () {
|
|
60
68
|
outer.state.connectionClosed();
|
|
61
69
|
outer.replayRequestsOnOpen = new Map(outer.runningRequestsParameters);
|
|
62
|
-
|
|
70
|
+
outer.debug("close");
|
|
63
71
|
};
|
|
64
72
|
this.websocket.onmessage = function (e) {
|
|
65
73
|
outer.processWebsocketMessageEvent(e);
|
|
@@ -119,22 +127,27 @@ export class MdsConnection {
|
|
|
119
127
|
new Observable((subscriber) => {
|
|
120
128
|
this.authdataCallback().then((mdsAuthdata) => outer.observable({ 'subscribeAuthentication': mdsAuthdata }, true)).then((observable) => observable.subscribe({
|
|
121
129
|
next(x) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
outer.
|
|
130
|
+
if (x.dataAuthentication.secondsToLive > 30) {
|
|
131
|
+
subscriber.next(x);
|
|
132
|
+
for (const json of outer.waitingForAuthentification) {
|
|
133
|
+
outer.websocket.send(JSON.stringify(json));
|
|
134
|
+
}
|
|
135
|
+
outer.waitingForAuthentification = [];
|
|
136
|
+
outer.state.authenticationAccepted();
|
|
125
137
|
}
|
|
126
|
-
outer.waitingForAuthentification = [];
|
|
127
138
|
},
|
|
128
139
|
complete() {
|
|
140
|
+
outer.state.authenticationEnded();
|
|
129
141
|
subscriber.complete();
|
|
130
142
|
},
|
|
131
143
|
error() {
|
|
144
|
+
outer.state.authenticationEnded();
|
|
132
145
|
subscriber.complete();
|
|
133
146
|
}
|
|
134
147
|
}));
|
|
135
148
|
})
|
|
136
149
|
.pipe(repeat({ delay: 2000 }))
|
|
137
|
-
.subscribe((c) =>
|
|
150
|
+
.subscribe((c) => outer.debug("auth outer " + c));
|
|
138
151
|
}
|
|
139
152
|
generateNextRequestId() {
|
|
140
153
|
return "request-" + this.counter++;
|
|
@@ -173,7 +186,7 @@ export class MdsConnection {
|
|
|
173
186
|
}
|
|
174
187
|
processWebsocketMessageEvent(e) {
|
|
175
188
|
const msg = JSON.parse(e.data);
|
|
176
|
-
|
|
189
|
+
this.debug("we received " + JSON.stringify(msg));
|
|
177
190
|
const promise = this.runningRequestsPromise.get(msg.requestId);
|
|
178
191
|
const subscriber = this.runningRequestsObservable.get(msg.requestId);
|
|
179
192
|
if (promise) {
|
|
@@ -209,4 +222,8 @@ export class MdsConnection {
|
|
|
209
222
|
}
|
|
210
223
|
}
|
|
211
224
|
}
|
|
225
|
+
debug(s) {
|
|
226
|
+
if (this.isDebug)
|
|
227
|
+
console.log(s);
|
|
228
|
+
}
|
|
212
229
|
}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -15,8 +15,11 @@ export declare class MdsConnectionState {
|
|
|
15
15
|
isAuthenticated: boolean;
|
|
16
16
|
connectionOpened(): void;
|
|
17
17
|
connectionClosed(): void;
|
|
18
|
+
authenticationAccepted(): void;
|
|
19
|
+
authenticationEnded(): void;
|
|
18
20
|
}
|
|
19
21
|
export type Options = {
|
|
22
|
+
debug?: boolean;
|
|
20
23
|
wsOptions?: ReconnectingWebSocketOptions;
|
|
21
24
|
};
|
|
22
25
|
export declare class MdsConnection {
|
|
@@ -30,6 +33,7 @@ export declare class MdsConnection {
|
|
|
30
33
|
private readonly runningRequestsParameters;
|
|
31
34
|
private replayRequestsOnOpen;
|
|
32
35
|
private readonly authdataCallback;
|
|
36
|
+
private isDebug;
|
|
33
37
|
constructor(websocketUrl: string, authdataCallback: () => Promise<MdsAuthdata>, options?: Options);
|
|
34
38
|
heartbeat(): Observable<String>;
|
|
35
39
|
marketstates(marketstateQueries: String[]): Observable<MarketstateUpdate>;
|
|
@@ -42,5 +46,6 @@ export declare class MdsConnection {
|
|
|
42
46
|
private observable;
|
|
43
47
|
private promise;
|
|
44
48
|
private processWebsocketMessageEvent;
|
|
49
|
+
private debug;
|
|
45
50
|
}
|
|
46
51
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAqB,MAAM,MAAM,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAC,iBAAiB,EAAqD,MAAM,4BAA4B,CAAA;AAGhH,qBAAa,WAAW;IAEb,KAAK,EAAE,MAAM,CAAC;gBAET,KAAK,EAAE,MAAM;CAI5B;AAID,qBAAa,iBAAiB;IAEnB,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAG,iBAAiB,CAAA;gBAErB,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG;CAKtC;AAED,qBAAa,kBAAkB;IACpB,WAAW,EAAG,OAAO,CAAS;IAC9B,eAAe,EAAG,OAAO,CAAS;IAEzC,gBAAgB;IAKhB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAqB,MAAM,MAAM,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAC,iBAAiB,EAAqD,MAAM,4BAA4B,CAAA;AAGhH,qBAAa,WAAW;IAEb,KAAK,E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