@bringg/dashboard-sdk 1.4.0 → 1.4.1
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/Services/PersistentConnection.d.ts +0 -13
- package/dist/Services/PersistentConnection.js +2 -59
- package/dist/Services/PersistentConnection.js.map +1 -1
- package/dist/Services/PubSubEvents.d.ts +0 -3
- package/dist/Services/PubSubEvents.js +1 -2
- package/dist/Services/PubSubEvents.js.map +1 -1
- package/dist/Services/ServiceRequest.js +1 -1
- package/dist/bringg-dashboard-sdk-cjs2.js +4 -62
- package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
- package/dist/bringg-dashboard-sdk.js +3 -3
- package/dist/bringg-dashboard-sdk.min.js +2 -2
- package/dist/bringg-dashboard-sdk.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import Session from './Identity/Session';
|
|
3
2
|
import User from './Identity/User';
|
|
4
3
|
import { Notifiable, RealtimeConnection } from './RealtimeConnection';
|
|
@@ -10,18 +9,9 @@ export declare class UserWireMessage {
|
|
|
10
9
|
bringg_user_id: string;
|
|
11
10
|
constructor(user: User);
|
|
12
11
|
}
|
|
13
|
-
export declare class BringgAlive {
|
|
14
|
-
lastUpdate: number;
|
|
15
|
-
pending: Map<string, number>;
|
|
16
|
-
constructor();
|
|
17
|
-
add(id: string): void;
|
|
18
|
-
resolve(id: string): void;
|
|
19
|
-
}
|
|
20
12
|
export default class PersistentConnection implements Notifiable {
|
|
21
13
|
session: Session;
|
|
22
|
-
bringgAlive: BringgAlive;
|
|
23
14
|
connection: RealtimeConnection;
|
|
24
|
-
timeout: NodeJS.Timeout;
|
|
25
15
|
static wrapEventHandler(eventName: string, initialHandler: any, additionalHandler?: (string: any, any: any) => void): (any: any) => void;
|
|
26
16
|
static init(session: Session): Promise<PersistentConnection>;
|
|
27
17
|
private constructor();
|
|
@@ -35,7 +25,4 @@ export default class PersistentConnection implements Notifiable {
|
|
|
35
25
|
publish<T>(ev: PubSubEvent<T>, mess: T, ackCallback?: (message: any | undefined) => void): void;
|
|
36
26
|
subscribe<T>(eventType: PubSubEvent<T>, handler: (message: T) => void): void;
|
|
37
27
|
dispose(): Promise<void>;
|
|
38
|
-
private setIntervalInternal;
|
|
39
|
-
private clearIntervalInternal;
|
|
40
|
-
initBringgAlive(): void;
|
|
41
28
|
}
|
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.UserWireMessage = exports.REALTIME_CONNECTION_RETRY_TIME = void 0;
|
|
40
40
|
var Logger_1 = require("../Core/Logger");
|
|
41
41
|
var RealtimeConnection_1 = require("./RealtimeConnection");
|
|
42
42
|
var Polly_1 = require("../Core/Polly");
|
|
@@ -51,38 +51,8 @@ var UserWireMessage = /** @class */ (function () {
|
|
|
51
51
|
return UserWireMessage;
|
|
52
52
|
}());
|
|
53
53
|
exports.UserWireMessage = UserWireMessage;
|
|
54
|
-
var BringgAlive = /** @class */ (function () {
|
|
55
|
-
function BringgAlive() {
|
|
56
|
-
this.lastUpdate = -1;
|
|
57
|
-
this.pending = new Map();
|
|
58
|
-
}
|
|
59
|
-
BringgAlive.prototype.add = function (id) {
|
|
60
|
-
var now = Date.now();
|
|
61
|
-
this.lastUpdate = now;
|
|
62
|
-
this.pending.set(id, now);
|
|
63
|
-
};
|
|
64
|
-
BringgAlive.prototype.resolve = function (id) {
|
|
65
|
-
try {
|
|
66
|
-
var now = Date.now();
|
|
67
|
-
Logger_1.default.debug("BringgAlive received [".concat(id, "] ..."));
|
|
68
|
-
this.lastUpdate = now;
|
|
69
|
-
if (this.pending.has(id)) {
|
|
70
|
-
Logger_1.default.debug("BringgAlive took [".concat(now - this.pending.get(id), "] ms. [").concat(this.pending.size - 1, "] pending ..."));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
Logger_1.default.warn("BringgAlive id [".concat(id, "] does not exist"));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
this.pending.delete(id);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
return BringgAlive;
|
|
81
|
-
}());
|
|
82
|
-
exports.BringgAlive = BringgAlive;
|
|
83
54
|
var PersistentConnection = /** @class */ (function () {
|
|
84
55
|
function PersistentConnection(session) {
|
|
85
|
-
this.bringgAlive = null;
|
|
86
56
|
this.session = session;
|
|
87
57
|
}
|
|
88
58
|
PersistentConnection.wrapEventHandler = function (eventName, initialHandler, additionalHandler) {
|
|
@@ -104,7 +74,6 @@ var PersistentConnection = /** @class */ (function () {
|
|
|
104
74
|
return [4 /*yield*/, RealtimeConnection_1.RealtimeConnection.connect(session.config.getMonitoringEndpoint(), _this)];
|
|
105
75
|
case 1:
|
|
106
76
|
_a.connection = _b.sent();
|
|
107
|
-
_this.initBringgAlive();
|
|
108
77
|
return [2 /*return*/, _this];
|
|
109
78
|
}
|
|
110
79
|
});
|
|
@@ -181,10 +150,7 @@ var PersistentConnection = /** @class */ (function () {
|
|
|
181
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
182
151
|
return __generator(this, function (_a) {
|
|
183
152
|
switch (_a.label) {
|
|
184
|
-
case 0:
|
|
185
|
-
this.clearIntervalInternal();
|
|
186
|
-
this.unsubscribe(PubSubEvents_1.BRINGG_ALIVE_EVENT);
|
|
187
|
-
return [4 /*yield*/, this.connection.disconnect()];
|
|
153
|
+
case 0: return [4 /*yield*/, this.connection.disconnect()];
|
|
188
154
|
case 1:
|
|
189
155
|
_a.sent();
|
|
190
156
|
return [2 /*return*/];
|
|
@@ -192,29 +158,6 @@ var PersistentConnection = /** @class */ (function () {
|
|
|
192
158
|
});
|
|
193
159
|
});
|
|
194
160
|
};
|
|
195
|
-
PersistentConnection.prototype.setIntervalInternal = function (func) {
|
|
196
|
-
this.timeout = setInterval(func, exports.REALTIME_CONNECTION_RETRY_TIME);
|
|
197
|
-
};
|
|
198
|
-
PersistentConnection.prototype.clearIntervalInternal = function () {
|
|
199
|
-
if (this.timeout) {
|
|
200
|
-
clearInterval(this.timeout);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
PersistentConnection.prototype.initBringgAlive = function () {
|
|
204
|
-
var self = this;
|
|
205
|
-
this.bringgAlive = new BringgAlive();
|
|
206
|
-
this.setIntervalInternal(function () {
|
|
207
|
-
var randomNumber = "".concat(Math.floor(Math.random() * 1000));
|
|
208
|
-
self.bringgAlive.add(randomNumber);
|
|
209
|
-
Logger_1.default.debug("Sending BringgAlive ".concat(randomNumber));
|
|
210
|
-
self.publish(PubSubEvents_1.BRINGG_ALIVE_EVENT, { keepalive_id: randomNumber }, function () {
|
|
211
|
-
Logger_1.default.debug("BringgAlive callback is OK");
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
this.subscribe(PubSubEvents_1.BRINGG_ALIVE_EVENT, function (data) {
|
|
215
|
-
self.bringgAlive.resolve(data.keepalive_id);
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
161
|
return PersistentConnection;
|
|
219
162
|
}());
|
|
220
163
|
exports.default = PersistentConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistentConnection.js","sourceRoot":"","sources":["../../src/Services/PersistentConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AAGpC,2DAAsE;AACtE,uCAAkC;AAClC,+
|
|
1
|
+
{"version":3,"file":"PersistentConnection.js","sourceRoot":"","sources":["../../src/Services/PersistentConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AAGpC,2DAAsE;AACtE,uCAAkC;AAClC,+CAA2F;AAE9E,QAAA,8BAA8B,GAAG,IAAI,CA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C,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAEM,sCAAO,GAAd,UAAkB,EAAkB,EAAE,IAAO,EAAE,WAAgD;QAC9F,IAAI,CAAC,eAAe,CAAI,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;IAEM,wCAAS,GAAhB,UAAoB,SAAyB,EAAE,OAA6B;QAC3E,IAAI,CAAC,iBAAiB,CAAI,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAEY,sCAAO,GAApB;;;;4BACC,qBAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAA;;wBAAlC,SAAkC,CAAC;;;;;KACnC;IACF,2BAAC;AAAD,CAAC,AAhGD,IAgGC"}
|
|
@@ -15,9 +15,6 @@ export declare const SUBSCRIBE_AS_ADMIN_EVENT: PubSubEvent<{
|
|
|
15
15
|
export declare const USER_CONNECT_SUCCESS_EVENT: PubSubEvent<{
|
|
16
16
|
bringg_user_id: string;
|
|
17
17
|
}>;
|
|
18
|
-
export declare const BRINGG_ALIVE_EVENT: PubSubEvent<{
|
|
19
|
-
keepalive_id: string;
|
|
20
|
-
}>;
|
|
21
18
|
export declare const MERCHANT_UPDATE: PubSubEvent<{
|
|
22
19
|
merchant: Merchant;
|
|
23
20
|
merchant_id: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZIP_CODES_UPLOAD_DONE = exports.NEW_EMPLOYEE = exports.DELETE_EMPLOYEE = exports.NEW_TASK = exports.TASK_DELETED = exports.NEW_NOTE = exports.NEW_SCAN = exports.WAYPOINT_UPDATED = exports.WAYPOINT_DELETED = exports.WAYPOINT_ADDED = exports.TASK_UPDATE = exports.MERCHANT_SUBSCRIPTION_UPDATE = exports.MERCHANT_UPDATE = exports.
|
|
3
|
+
exports.ZIP_CODES_UPLOAD_DONE = exports.NEW_EMPLOYEE = exports.DELETE_EMPLOYEE = exports.NEW_TASK = exports.TASK_DELETED = exports.NEW_NOTE = exports.NEW_SCAN = exports.WAYPOINT_UPDATED = exports.WAYPOINT_DELETED = exports.WAYPOINT_ADDED = exports.TASK_UPDATE = exports.MERCHANT_SUBSCRIPTION_UPDATE = exports.MERCHANT_UPDATE = exports.USER_CONNECT_SUCCESS_EVENT = exports.SUBSCRIBE_AS_ADMIN_EVENT = exports.EMPLOYEE_UPDATE_EVENT = exports.USER_CONNECT_EVENT = exports.PubSubEvent = void 0;
|
|
4
4
|
var PubSubEvent = /** @class */ (function () {
|
|
5
5
|
function PubSubEvent(name) {
|
|
6
6
|
this.name = name;
|
|
@@ -12,7 +12,6 @@ exports.USER_CONNECT_EVENT = new PubSubEvent('user connect');
|
|
|
12
12
|
exports.EMPLOYEE_UPDATE_EVENT = new PubSubEvent('employee update');
|
|
13
13
|
exports.SUBSCRIBE_AS_ADMIN_EVENT = new PubSubEvent('subscribe as admin');
|
|
14
14
|
exports.USER_CONNECT_SUCCESS_EVENT = new PubSubEvent('connect success');
|
|
15
|
-
exports.BRINGG_ALIVE_EVENT = new PubSubEvent('b');
|
|
16
15
|
exports.MERCHANT_UPDATE = new PubSubEvent('merchant update');
|
|
17
16
|
exports.MERCHANT_SUBSCRIPTION_UPDATE = new PubSubEvent('merchant subscription updated');
|
|
18
17
|
exports.TASK_UPDATE = new PubSubEvent('task update');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSubEvents.js","sourceRoot":"","sources":["../../src/Services/PubSubEvents.ts"],"names":[],"mappings":";;;AAEA;IAGC,qBAAY,IAAY;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IACF,kBAAC;AAAD,CAAC,AAND,IAMC;AANY,kCAAW;AAQX,QAAA,kBAAkB,GAAG,IAA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D,QAAA,YAAY,GAAG,IAAI,WAAW,CAAO,cAAc,CAAC,CAAC;AACrD,QAAA,QAAQ,GAAG,IAAI,WAAW,CAAO,UAAU,CAAC,CAAC;AAE7C,QAAA,eAAe,GAAG,IAAI,WAAW,CAAsB,iBAAiB,CAAC,CAAC;AAC1E,QAAA,YAAY,GAAG,IAAI,WAAW,CAAO,cAAc,CAAC,CAAC;AACrD,QAAA,qBAAqB,GAAG,IAAI,WAAW,CAAO,4BAA4B,CAAC,CAAC"}
|
|
@@ -52,7 +52,7 @@ var axios_1 = require("axios");
|
|
|
52
52
|
var Logger_1 = require("../Core/Logger");
|
|
53
53
|
var lodash_1 = require("lodash");
|
|
54
54
|
var BringgException_1 = require("../Core/BringgException");
|
|
55
|
-
var version = '1.4.
|
|
55
|
+
var version = '1.4.1';
|
|
56
56
|
function logErrorResponse(response) {
|
|
57
57
|
var data = response.data, status = response.status;
|
|
58
58
|
try {
|
|
@@ -22942,7 +22942,7 @@ exports.default = URLEndpoint;
|
|
|
22942
22942
|
"use strict";
|
|
22943
22943
|
|
|
22944
22944
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22945
|
-
exports.ZIP_CODES_UPLOAD_DONE = exports.NEW_EMPLOYEE = exports.DELETE_EMPLOYEE = exports.NEW_TASK = exports.TASK_DELETED = exports.NEW_NOTE = exports.NEW_SCAN = exports.WAYPOINT_UPDATED = exports.WAYPOINT_DELETED = exports.WAYPOINT_ADDED = exports.TASK_UPDATE = exports.MERCHANT_SUBSCRIPTION_UPDATE = exports.MERCHANT_UPDATE = exports.
|
|
22945
|
+
exports.ZIP_CODES_UPLOAD_DONE = exports.NEW_EMPLOYEE = exports.DELETE_EMPLOYEE = exports.NEW_TASK = exports.TASK_DELETED = exports.NEW_NOTE = exports.NEW_SCAN = exports.WAYPOINT_UPDATED = exports.WAYPOINT_DELETED = exports.WAYPOINT_ADDED = exports.TASK_UPDATE = exports.MERCHANT_SUBSCRIPTION_UPDATE = exports.MERCHANT_UPDATE = exports.USER_CONNECT_SUCCESS_EVENT = exports.SUBSCRIBE_AS_ADMIN_EVENT = exports.EMPLOYEE_UPDATE_EVENT = exports.USER_CONNECT_EVENT = exports.PubSubEvent = void 0;
|
|
22946
22946
|
var PubSubEvent = /** @class */ (function () {
|
|
22947
22947
|
function PubSubEvent(name) {
|
|
22948
22948
|
this.name = name;
|
|
@@ -22954,7 +22954,6 @@ exports.USER_CONNECT_EVENT = new PubSubEvent('user connect');
|
|
|
22954
22954
|
exports.EMPLOYEE_UPDATE_EVENT = new PubSubEvent('employee update');
|
|
22955
22955
|
exports.SUBSCRIBE_AS_ADMIN_EVENT = new PubSubEvent('subscribe as admin');
|
|
22956
22956
|
exports.USER_CONNECT_SUCCESS_EVENT = new PubSubEvent('connect success');
|
|
22957
|
-
exports.BRINGG_ALIVE_EVENT = new PubSubEvent('b');
|
|
22958
22957
|
exports.MERCHANT_UPDATE = new PubSubEvent('merchant update');
|
|
22959
22958
|
exports.MERCHANT_SUBSCRIPTION_UPDATE = new PubSubEvent('merchant subscription updated');
|
|
22960
22959
|
exports.TASK_UPDATE = new PubSubEvent('task update');
|
|
@@ -28287,7 +28286,7 @@ var axios_1 = __webpack_require__(147);
|
|
|
28287
28286
|
var Logger_1 = __webpack_require__(43);
|
|
28288
28287
|
var lodash_1 = __webpack_require__(10);
|
|
28289
28288
|
var BringgException_1 = __webpack_require__(14);
|
|
28290
|
-
var version = '1.4.
|
|
28289
|
+
var version = '1.4.1';
|
|
28291
28290
|
function logErrorResponse(response) {
|
|
28292
28291
|
var data = response.data, status = response.status;
|
|
28293
28292
|
try {
|
|
@@ -38159,7 +38158,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38159
38158
|
}
|
|
38160
38159
|
};
|
|
38161
38160
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38162
|
-
exports.
|
|
38161
|
+
exports.UserWireMessage = exports.REALTIME_CONNECTION_RETRY_TIME = void 0;
|
|
38163
38162
|
var Logger_1 = __webpack_require__(43);
|
|
38164
38163
|
var RealtimeConnection_1 = __webpack_require__(175);
|
|
38165
38164
|
var Polly_1 = __webpack_require__(176);
|
|
@@ -38174,38 +38173,8 @@ var UserWireMessage = /** @class */ (function () {
|
|
|
38174
38173
|
return UserWireMessage;
|
|
38175
38174
|
}());
|
|
38176
38175
|
exports.UserWireMessage = UserWireMessage;
|
|
38177
|
-
var BringgAlive = /** @class */ (function () {
|
|
38178
|
-
function BringgAlive() {
|
|
38179
|
-
this.lastUpdate = -1;
|
|
38180
|
-
this.pending = new Map();
|
|
38181
|
-
}
|
|
38182
|
-
BringgAlive.prototype.add = function (id) {
|
|
38183
|
-
var now = Date.now();
|
|
38184
|
-
this.lastUpdate = now;
|
|
38185
|
-
this.pending.set(id, now);
|
|
38186
|
-
};
|
|
38187
|
-
BringgAlive.prototype.resolve = function (id) {
|
|
38188
|
-
try {
|
|
38189
|
-
var now = Date.now();
|
|
38190
|
-
Logger_1.default.debug("BringgAlive received [".concat(id, "] ..."));
|
|
38191
|
-
this.lastUpdate = now;
|
|
38192
|
-
if (this.pending.has(id)) {
|
|
38193
|
-
Logger_1.default.debug("BringgAlive took [".concat(now - this.pending.get(id), "] ms. [").concat(this.pending.size - 1, "] pending ..."));
|
|
38194
|
-
}
|
|
38195
|
-
else {
|
|
38196
|
-
Logger_1.default.warn("BringgAlive id [".concat(id, "] does not exist"));
|
|
38197
|
-
}
|
|
38198
|
-
}
|
|
38199
|
-
finally {
|
|
38200
|
-
this.pending.delete(id);
|
|
38201
|
-
}
|
|
38202
|
-
};
|
|
38203
|
-
return BringgAlive;
|
|
38204
|
-
}());
|
|
38205
|
-
exports.BringgAlive = BringgAlive;
|
|
38206
38176
|
var PersistentConnection = /** @class */ (function () {
|
|
38207
38177
|
function PersistentConnection(session) {
|
|
38208
|
-
this.bringgAlive = null;
|
|
38209
38178
|
this.session = session;
|
|
38210
38179
|
}
|
|
38211
38180
|
PersistentConnection.wrapEventHandler = function (eventName, initialHandler, additionalHandler) {
|
|
@@ -38227,7 +38196,6 @@ var PersistentConnection = /** @class */ (function () {
|
|
|
38227
38196
|
return [4 /*yield*/, RealtimeConnection_1.RealtimeConnection.connect(session.config.getMonitoringEndpoint(), _this)];
|
|
38228
38197
|
case 1:
|
|
38229
38198
|
_a.connection = _b.sent();
|
|
38230
|
-
_this.initBringgAlive();
|
|
38231
38199
|
return [2 /*return*/, _this];
|
|
38232
38200
|
}
|
|
38233
38201
|
});
|
|
@@ -38304,10 +38272,7 @@ var PersistentConnection = /** @class */ (function () {
|
|
|
38304
38272
|
return __awaiter(this, void 0, void 0, function () {
|
|
38305
38273
|
return __generator(this, function (_a) {
|
|
38306
38274
|
switch (_a.label) {
|
|
38307
|
-
case 0:
|
|
38308
|
-
this.clearIntervalInternal();
|
|
38309
|
-
this.unsubscribe(PubSubEvents_1.BRINGG_ALIVE_EVENT);
|
|
38310
|
-
return [4 /*yield*/, this.connection.disconnect()];
|
|
38275
|
+
case 0: return [4 /*yield*/, this.connection.disconnect()];
|
|
38311
38276
|
case 1:
|
|
38312
38277
|
_a.sent();
|
|
38313
38278
|
return [2 /*return*/];
|
|
@@ -38315,29 +38280,6 @@ var PersistentConnection = /** @class */ (function () {
|
|
|
38315
38280
|
});
|
|
38316
38281
|
});
|
|
38317
38282
|
};
|
|
38318
|
-
PersistentConnection.prototype.setIntervalInternal = function (func) {
|
|
38319
|
-
this.timeout = setInterval(func, exports.REALTIME_CONNECTION_RETRY_TIME);
|
|
38320
|
-
};
|
|
38321
|
-
PersistentConnection.prototype.clearIntervalInternal = function () {
|
|
38322
|
-
if (this.timeout) {
|
|
38323
|
-
clearInterval(this.timeout);
|
|
38324
|
-
}
|
|
38325
|
-
};
|
|
38326
|
-
PersistentConnection.prototype.initBringgAlive = function () {
|
|
38327
|
-
var self = this;
|
|
38328
|
-
this.bringgAlive = new BringgAlive();
|
|
38329
|
-
this.setIntervalInternal(function () {
|
|
38330
|
-
var randomNumber = "".concat(Math.floor(Math.random() * 1000));
|
|
38331
|
-
self.bringgAlive.add(randomNumber);
|
|
38332
|
-
Logger_1.default.debug("Sending BringgAlive ".concat(randomNumber));
|
|
38333
|
-
self.publish(PubSubEvents_1.BRINGG_ALIVE_EVENT, { keepalive_id: randomNumber }, function () {
|
|
38334
|
-
Logger_1.default.debug("BringgAlive callback is OK");
|
|
38335
|
-
});
|
|
38336
|
-
});
|
|
38337
|
-
this.subscribe(PubSubEvents_1.BRINGG_ALIVE_EVENT, function (data) {
|
|
38338
|
-
self.bringgAlive.resolve(data.keepalive_id);
|
|
38339
|
-
});
|
|
38340
|
-
};
|
|
38341
38283
|
return PersistentConnection;
|
|
38342
38284
|
}());
|
|
38343
38285
|
exports.default = PersistentConnection;
|