@stryke-xyz/premarket-sdk 1.2.2 → 1.2.4
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/dist/cjs/api/README.md +296 -0
- package/dist/cjs/config/README.md +112 -0
- package/dist/cjs/config/index.js +4 -4
- package/dist/cjs/exchange/README.md +280 -0
- package/dist/cjs/registry/README.md +150 -0
- package/dist/cjs/shared/README.md +235 -0
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/sync/README.md +215 -0
- package/dist/cjs/sync/clients/base-client.js +518 -0
- package/dist/cjs/sync/redis-ws-client.js +235 -0
- package/dist/cjs/utils/README.md +89 -0
- package/dist/cjs/vault/README.md +268 -0
- package/dist/esm/api/README.md +296 -0
- package/dist/esm/config/README.md +112 -0
- package/dist/esm/config/index.js +4 -4
- package/dist/esm/exchange/README.md +280 -0
- package/dist/esm/registry/README.md +150 -0
- package/dist/esm/shared/README.md +235 -0
- package/dist/esm/shared/utils.js +0 -0
- package/dist/esm/sync/README.md +215 -0
- package/dist/esm/sync/clients/base-client.js +508 -0
- package/dist/esm/sync/redis-ws-client.js +225 -0
- package/dist/esm/utils/README.md +89 -0
- package/dist/esm/vault/README.md +268 -0
- package/dist/types/shared/utils.d.ts +0 -0
- package/dist/types/sync/clients/base-client.d.ts +56 -0
- package/dist/types/sync/redis-ws-client.d.ts +21 -0
- package/package.json +58 -58
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _class_call_check(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _defineProperties(target, props) {
|
|
36
|
+
for(var i = 0; i < props.length; i++){
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
48
|
+
}
|
|
49
|
+
function _define_property(obj, key, value) {
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
function _ts_generator(thisArg, body) {
|
|
63
|
+
var f, y, t, _ = {
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
72
|
+
return d(g, "next", {
|
|
73
|
+
value: verb(0)
|
|
74
|
+
}), d(g, "throw", {
|
|
75
|
+
value: verb(1)
|
|
76
|
+
}), d(g, "return", {
|
|
77
|
+
value: verb(2)
|
|
78
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
79
|
+
value: function() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
}), g;
|
|
83
|
+
function verb(n) {
|
|
84
|
+
return function(v) {
|
|
85
|
+
return step([
|
|
86
|
+
n,
|
|
87
|
+
v
|
|
88
|
+
]);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function step(op) {
|
|
92
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
93
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
94
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
95
|
+
if (y = 0, t) op = [
|
|
96
|
+
op[0] & 2,
|
|
97
|
+
t.value
|
|
98
|
+
];
|
|
99
|
+
switch(op[0]){
|
|
100
|
+
case 0:
|
|
101
|
+
case 1:
|
|
102
|
+
t = op;
|
|
103
|
+
break;
|
|
104
|
+
case 4:
|
|
105
|
+
_.label++;
|
|
106
|
+
return {
|
|
107
|
+
value: op[1],
|
|
108
|
+
done: false
|
|
109
|
+
};
|
|
110
|
+
case 5:
|
|
111
|
+
_.label++;
|
|
112
|
+
y = op[1];
|
|
113
|
+
op = [
|
|
114
|
+
0
|
|
115
|
+
];
|
|
116
|
+
continue;
|
|
117
|
+
case 7:
|
|
118
|
+
op = _.ops.pop();
|
|
119
|
+
_.trys.pop();
|
|
120
|
+
continue;
|
|
121
|
+
default:
|
|
122
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
123
|
+
_ = 0;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
127
|
+
_.label = op[1];
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
131
|
+
_.label = t[1];
|
|
132
|
+
t = op;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (t && _.label < t[2]) {
|
|
136
|
+
_.label = t[2];
|
|
137
|
+
_.ops.push(op);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (t[2]) _.ops.pop();
|
|
141
|
+
_.trys.pop();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
op = body.call(thisArg, _);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
op = [
|
|
147
|
+
6,
|
|
148
|
+
e
|
|
149
|
+
];
|
|
150
|
+
y = 0;
|
|
151
|
+
} finally{
|
|
152
|
+
f = t = 0;
|
|
153
|
+
}
|
|
154
|
+
if (op[0] & 5) throw op[1];
|
|
155
|
+
return {
|
|
156
|
+
value: op[0] ? op[1] : void 0,
|
|
157
|
+
done: true
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
import { RedisWsClient } from "../redis-ws-client.js";
|
|
162
|
+
function scheduleDeferred(callback) {
|
|
163
|
+
if (typeof queueMicrotask === "function") {
|
|
164
|
+
queueMicrotask(callback);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
setTimeout(callback, 0);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Base abstract class for sync clients
|
|
171
|
+
* @template TMessage - The message type (e.g., SequencedMessage, BalanceUpdateMessage)
|
|
172
|
+
* @template TChange - The change type (e.g., OrderChange, BalanceData[])
|
|
173
|
+
* @template TData - The data type stored in the map (e.g., StoredOrder, string)
|
|
174
|
+
* @template TConfig - The config type (must have redisUrl and channel)
|
|
175
|
+
*/ export var BaseSyncClient = /*#__PURE__*/ function() {
|
|
176
|
+
"use strict";
|
|
177
|
+
function BaseSyncClient(config) {
|
|
178
|
+
_class_call_check(this, BaseSyncClient);
|
|
179
|
+
_define_property(this, "wsClient", null);
|
|
180
|
+
_define_property(this, "config", void 0);
|
|
181
|
+
_define_property(this, "status", "disconnected");
|
|
182
|
+
_define_property(this, "lastSeq", 0);
|
|
183
|
+
_define_property(this, "incomingQueue", []);
|
|
184
|
+
_define_property(this, "isProcessing", false);
|
|
185
|
+
_define_property(this, "statusListeners", new Set());
|
|
186
|
+
_define_property(this, "changeListeners", new Set());
|
|
187
|
+
_define_property(this, "dataMap", new Map());
|
|
188
|
+
_define_property(this, "snapshotListeners", new Set());
|
|
189
|
+
this.config = config;
|
|
190
|
+
}
|
|
191
|
+
_create_class(BaseSyncClient, [
|
|
192
|
+
{
|
|
193
|
+
key: "connect",
|
|
194
|
+
value: /** Opens the websocket subscription, fetches a fresh snapshot, and starts replaying queued messages. */ function connect() {
|
|
195
|
+
return _async_to_generator(function() {
|
|
196
|
+
var _this, wsUrl;
|
|
197
|
+
return _ts_generator(this, function(_state) {
|
|
198
|
+
switch(_state.label){
|
|
199
|
+
case 0:
|
|
200
|
+
_this = this;
|
|
201
|
+
// Disconnect existing connection if any (for restarts)
|
|
202
|
+
return [
|
|
203
|
+
4,
|
|
204
|
+
this.disconnect()
|
|
205
|
+
];
|
|
206
|
+
case 1:
|
|
207
|
+
_state.sent();
|
|
208
|
+
this.setStatus("connecting");
|
|
209
|
+
// Only allow ws:// or wss:// URLs
|
|
210
|
+
wsUrl = this.config.redisUrl;
|
|
211
|
+
if (!wsUrl.startsWith("ws://") && !wsUrl.startsWith("wss://")) {
|
|
212
|
+
throw new Error("Invalid WebSocket URL: ".concat(wsUrl, ". Only ws:// and wss:// URLs are supported."));
|
|
213
|
+
}
|
|
214
|
+
// Set isProcessing to true to prevent queue processing until snapshot is fetched
|
|
215
|
+
this.isProcessing = true;
|
|
216
|
+
// Start WebSocket connection first (messages will be queued)
|
|
217
|
+
this.wsClient = new RedisWsClient(wsUrl);
|
|
218
|
+
this.wsClient.subscribe(this.config.channel, function(messageStr) {
|
|
219
|
+
try {
|
|
220
|
+
var message = JSON.parse(messageStr);
|
|
221
|
+
_this.enqueueMessage(message);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error("Error parsing message:", error);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
// Wait 200ms after subscription to ensure we don't miss any updates
|
|
227
|
+
// that might arrive immediately after subscribing
|
|
228
|
+
return [
|
|
229
|
+
4,
|
|
230
|
+
new Promise(function(resolve) {
|
|
231
|
+
return setTimeout(resolve, 200);
|
|
232
|
+
})
|
|
233
|
+
];
|
|
234
|
+
case 2:
|
|
235
|
+
_state.sent();
|
|
236
|
+
// Fetch snapshot while messages are being queued (but not processed)
|
|
237
|
+
this.setStatus("syncing");
|
|
238
|
+
return [
|
|
239
|
+
4,
|
|
240
|
+
this.fetchSnapshot()
|
|
241
|
+
];
|
|
242
|
+
case 3:
|
|
243
|
+
_state.sent();
|
|
244
|
+
// Now allow queue processing
|
|
245
|
+
this.isProcessing = false;
|
|
246
|
+
this.setStatus("synced");
|
|
247
|
+
// Start processing any queued messages
|
|
248
|
+
this.processQueue();
|
|
249
|
+
return [
|
|
250
|
+
2
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}).call(this);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
key: "enqueueMessage",
|
|
259
|
+
value: function enqueueMessage(message) {
|
|
260
|
+
this.incomingQueue.push(message);
|
|
261
|
+
this.processQueue();
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
key: "processQueue",
|
|
266
|
+
value: function processQueue() {
|
|
267
|
+
return _async_to_generator(function() {
|
|
268
|
+
var _this, message;
|
|
269
|
+
return _ts_generator(this, function(_state) {
|
|
270
|
+
switch(_state.label){
|
|
271
|
+
case 0:
|
|
272
|
+
_this = this;
|
|
273
|
+
if (this.isProcessing) return [
|
|
274
|
+
2
|
|
275
|
+
];
|
|
276
|
+
this.isProcessing = true;
|
|
277
|
+
_state.label = 1;
|
|
278
|
+
case 1:
|
|
279
|
+
_state.trys.push([
|
|
280
|
+
1,
|
|
281
|
+
,
|
|
282
|
+
9,
|
|
283
|
+
10
|
|
284
|
+
]);
|
|
285
|
+
_state.label = 2;
|
|
286
|
+
case 2:
|
|
287
|
+
if (!(this.incomingQueue.length > 0)) return [
|
|
288
|
+
3,
|
|
289
|
+
8
|
|
290
|
+
];
|
|
291
|
+
message = this.incomingQueue.shift();
|
|
292
|
+
// Skip if we've already processed this sequence ID
|
|
293
|
+
if (message.seq <= this.lastSeq) {
|
|
294
|
+
return [
|
|
295
|
+
3,
|
|
296
|
+
2
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
if (!// Check if previousSeq matches our lastSeq (no gap)
|
|
300
|
+
(message.previousSeq === this.lastSeq)) return [
|
|
301
|
+
3,
|
|
302
|
+
4
|
|
303
|
+
];
|
|
304
|
+
// Perfect! Process this message and update lastSeq
|
|
305
|
+
return [
|
|
306
|
+
4,
|
|
307
|
+
this.applyMessage(message)
|
|
308
|
+
];
|
|
309
|
+
case 3:
|
|
310
|
+
_state.sent();
|
|
311
|
+
this.lastSeq = message.seq;
|
|
312
|
+
return [
|
|
313
|
+
3,
|
|
314
|
+
7
|
|
315
|
+
];
|
|
316
|
+
case 4:
|
|
317
|
+
if (!(message.previousSeq < this.lastSeq)) return [
|
|
318
|
+
3,
|
|
319
|
+
5
|
|
320
|
+
];
|
|
321
|
+
// This message is out of order (previousSeq is behind us)
|
|
322
|
+
// This shouldn't happen in normal operation, but skip it
|
|
323
|
+
console.warn("Out of order message: previousSeq=".concat(message.previousSeq, ", lastSeq=").concat(this.lastSeq, ", seq=").concat(message.seq));
|
|
324
|
+
return [
|
|
325
|
+
3,
|
|
326
|
+
2
|
|
327
|
+
];
|
|
328
|
+
case 5:
|
|
329
|
+
// Gap detected: previousSeq > lastSeq
|
|
330
|
+
// Trigger full resync instead of gap recovery
|
|
331
|
+
console.warn("Gap detected: previousSeq=".concat(message.previousSeq, ", lastSeq=").concat(this.lastSeq, ", seq=").concat(message.seq, ". Triggering full resync."));
|
|
332
|
+
// Clear the queue - full resync will reconnect and start fresh
|
|
333
|
+
this.incomingQueue = [];
|
|
334
|
+
return [
|
|
335
|
+
4,
|
|
336
|
+
this.fullResync()
|
|
337
|
+
];
|
|
338
|
+
case 6:
|
|
339
|
+
_state.sent();
|
|
340
|
+
return [
|
|
341
|
+
3,
|
|
342
|
+
8
|
|
343
|
+
];
|
|
344
|
+
case 7:
|
|
345
|
+
return [
|
|
346
|
+
3,
|
|
347
|
+
2
|
|
348
|
+
];
|
|
349
|
+
case 8:
|
|
350
|
+
return [
|
|
351
|
+
3,
|
|
352
|
+
10
|
|
353
|
+
];
|
|
354
|
+
case 9:
|
|
355
|
+
this.isProcessing = false;
|
|
356
|
+
if (this.incomingQueue.length > 0) {
|
|
357
|
+
scheduleDeferred(function() {
|
|
358
|
+
void _this.processQueue();
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return [
|
|
362
|
+
7
|
|
363
|
+
];
|
|
364
|
+
case 10:
|
|
365
|
+
return [
|
|
366
|
+
2
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}).call(this);
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
key: "fullResync",
|
|
375
|
+
value: function fullResync() {
|
|
376
|
+
return _async_to_generator(function() {
|
|
377
|
+
return _ts_generator(this, function(_state) {
|
|
378
|
+
switch(_state.label){
|
|
379
|
+
case 0:
|
|
380
|
+
this.setStatus("recovering");
|
|
381
|
+
// Disconnect and reconnect to restart the flow
|
|
382
|
+
return [
|
|
383
|
+
4,
|
|
384
|
+
this.disconnect()
|
|
385
|
+
];
|
|
386
|
+
case 1:
|
|
387
|
+
_state.sent();
|
|
388
|
+
return [
|
|
389
|
+
4,
|
|
390
|
+
this.connect()
|
|
391
|
+
];
|
|
392
|
+
case 2:
|
|
393
|
+
_state.sent();
|
|
394
|
+
return [
|
|
395
|
+
2
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}).call(this);
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
key: "setStatus",
|
|
404
|
+
value: function setStatus(status) {
|
|
405
|
+
if (this.status === status) return;
|
|
406
|
+
this.status = status;
|
|
407
|
+
this.statusListeners.forEach(function(listener) {
|
|
408
|
+
try {
|
|
409
|
+
listener(status);
|
|
410
|
+
} catch (error) {
|
|
411
|
+
console.error("Error in status listener:", error);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
/** Returns the current connection lifecycle state. */ key: "getStatus",
|
|
418
|
+
value: function getStatus() {
|
|
419
|
+
return this.status;
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
/** Returns true once the client has finished its initial snapshot sync. */ key: "isSynced",
|
|
424
|
+
value: function isSynced() {
|
|
425
|
+
return this.status === "synced";
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
/** Returns the most recent successfully applied sequence id. */ key: "getLastSequence",
|
|
430
|
+
value: function getLastSequence() {
|
|
431
|
+
return this.lastSeq;
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
/** Returns the number of queued messages waiting to be processed. */ key: "getBufferedCount",
|
|
436
|
+
value: function getBufferedCount() {
|
|
437
|
+
return this.incomingQueue.length;
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
/** Registers a listener for connection status changes. */ key: "onStatus",
|
|
442
|
+
value: function onStatus(callback) {
|
|
443
|
+
var _this = this;
|
|
444
|
+
this.statusListeners.add(callback);
|
|
445
|
+
return function() {
|
|
446
|
+
return _this.statusListeners.delete(callback);
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
/** Registers a listener for individual applied change events. */ key: "onChange",
|
|
452
|
+
value: function onChange(callback) {
|
|
453
|
+
var _this = this;
|
|
454
|
+
this.changeListeners.add(callback);
|
|
455
|
+
return function() {
|
|
456
|
+
return _this.changeListeners.delete(callback);
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
/** Registers a listener for full snapshot updates. */ key: "onSnapshot",
|
|
462
|
+
value: function onSnapshot(callback) {
|
|
463
|
+
var _this = this;
|
|
464
|
+
this.snapshotListeners.add(callback);
|
|
465
|
+
return function() {
|
|
466
|
+
return _this.snapshotListeners.delete(callback);
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
key: "notifySnapshotListeners",
|
|
472
|
+
value: function notifySnapshotListeners(data) {
|
|
473
|
+
this.snapshotListeners.forEach(function(listener) {
|
|
474
|
+
try {
|
|
475
|
+
listener(data);
|
|
476
|
+
} catch (error) {
|
|
477
|
+
console.error("Error in snapshot listener:", error);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
key: "disconnect",
|
|
484
|
+
value: /** Closes the websocket connection and clears queued messages. */ function disconnect() {
|
|
485
|
+
return _async_to_generator(function() {
|
|
486
|
+
return _ts_generator(this, function(_state) {
|
|
487
|
+
// Stop processing
|
|
488
|
+
this.isProcessing = true;
|
|
489
|
+
// Clear WebSocket connection
|
|
490
|
+
if (this.wsClient) {
|
|
491
|
+
this.wsClient.close();
|
|
492
|
+
this.wsClient = null;
|
|
493
|
+
}
|
|
494
|
+
// Clear queue
|
|
495
|
+
this.incomingQueue = [];
|
|
496
|
+
this.setStatus("disconnected");
|
|
497
|
+
return [
|
|
498
|
+
2
|
|
499
|
+
];
|
|
500
|
+
});
|
|
501
|
+
}).call(this);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
]);
|
|
505
|
+
return BaseSyncClient;
|
|
506
|
+
} /**
|
|
507
|
+
* Abstract methods to be implemented by child classes
|
|
508
|
+
*/ ();
|