@resolveio/server-lib 5.1.1 → 5.1.2
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/package.json +1 -1
- package/server-app.js +41 -30
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -281,46 +281,57 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
281
281
|
}, 10000);
|
|
282
282
|
// On data received (message)
|
|
283
283
|
ws.on('message', function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
284
|
-
var _a, _b, socketData, data, messageDate, messageId, type, subType, pub;
|
|
284
|
+
var _a, _b, parseErrorFound, socketData, data, messageDate, messageId, type, subType, pub;
|
|
285
285
|
var _this = this;
|
|
286
286
|
return __generator(this, function (_c) {
|
|
287
287
|
if (this.LOGGER === 'DEBUG') {
|
|
288
288
|
console.log('Message from: ' + ws['user'], message);
|
|
289
289
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
ws.send('pong', function (error) {
|
|
295
|
-
if (error) {
|
|
296
|
-
console.log('Error on WS: ', error);
|
|
297
|
-
_this.unsubscribeWS(ws);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
return [2 /*return*/];
|
|
290
|
+
parseErrorFound = false;
|
|
291
|
+
socketData = null;
|
|
292
|
+
try {
|
|
293
|
+
socketData = JSON.parse(message, common_1.dateReviver);
|
|
302
294
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (
|
|
311
|
-
(
|
|
295
|
+
catch (e) {
|
|
296
|
+
console.log('Error - JSON.parse', message);
|
|
297
|
+
this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));
|
|
298
|
+
parseErrorFound = true;
|
|
299
|
+
}
|
|
300
|
+
if (!parseErrorFound) {
|
|
301
|
+
data = common_2.deepCopy(socketData);
|
|
302
|
+
if (data[0] === 'ping') {
|
|
303
|
+
if (ws && ws.readyState === ws.OPEN) {
|
|
304
|
+
ws.send('pong', function (error) {
|
|
305
|
+
if (error) {
|
|
306
|
+
console.log('Error on WS: ', error);
|
|
307
|
+
_this.unsubscribeWS(ws);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return [2 /*return*/];
|
|
312
|
+
}
|
|
313
|
+
messageDate = data.shift();
|
|
314
|
+
messageId = data.shift();
|
|
315
|
+
type = data.shift();
|
|
316
|
+
if (type === 'subscription') {
|
|
317
|
+
subType = data.shift();
|
|
318
|
+
pub = data.shift();
|
|
319
|
+
// Subscribe
|
|
320
|
+
if (subType === 'sub') {
|
|
321
|
+
(_a = this._subscriptionManager).subscribe.apply(_a, [messageDate, ws, messageId, pub].concat(data));
|
|
322
|
+
}
|
|
323
|
+
// Unsubscribe
|
|
324
|
+
else {
|
|
325
|
+
(_b = this._subscriptionManager).unsubscribe.apply(_b, [messageDate, ws, messageId, pub].concat(data));
|
|
326
|
+
}
|
|
312
327
|
}
|
|
313
|
-
// Unsubscribe
|
|
314
328
|
else {
|
|
315
|
-
|
|
329
|
+
this._msgQueue.splice(0, 0, {
|
|
330
|
+
ws: ws,
|
|
331
|
+
data: socketData
|
|
332
|
+
});
|
|
316
333
|
}
|
|
317
334
|
}
|
|
318
|
-
else {
|
|
319
|
-
this._msgQueue.splice(0, 0, {
|
|
320
|
-
ws: ws,
|
|
321
|
-
data: socketData
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
335
|
return [2 /*return*/];
|
|
325
336
|
});
|
|
326
337
|
}); });
|