@resolveio/server-lib 1.0.17 → 1.0.18
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.
|
@@ -12,7 +12,8 @@ export declare class SupportManager {
|
|
|
12
12
|
getMainServer(): ResolveIOMainServer;
|
|
13
13
|
supportMethods(supportMethod: SupportMethodModel): void;
|
|
14
14
|
callSupportMethod(ws: WebSocket, messageId: any, supportMethod: any, ...methodData: any[]): void;
|
|
15
|
-
|
|
15
|
+
callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
|
|
16
|
+
callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
|
|
16
17
|
private sendWS;
|
|
17
18
|
sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[]): void;
|
|
18
19
|
}
|
|
@@ -8,6 +8,7 @@ var counters_1 = require("../support-methods/counters");
|
|
|
8
8
|
var mongoose_1 = require("mongoose");
|
|
9
9
|
var common_1 = require("../util/common");
|
|
10
10
|
var log_collection_1 = require("../collections/log.collection");
|
|
11
|
+
var method_manager_1 = require("./method.manager");
|
|
11
12
|
var SupportManager = /** @class */ (function () {
|
|
12
13
|
function SupportManager(mainServer, serverConfig) {
|
|
13
14
|
var _this = this;
|
|
@@ -180,7 +181,7 @@ var SupportManager = /** @class */ (function () {
|
|
|
180
181
|
_this.sendWS(ws, supportMethod, methodData, serverRes);
|
|
181
182
|
});
|
|
182
183
|
};
|
|
183
|
-
SupportManager.prototype.
|
|
184
|
+
SupportManager.prototype.callSupportMethodInternal = function (supportMethod) {
|
|
184
185
|
var methodData = [];
|
|
185
186
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
186
187
|
methodData[_i - 1] = arguments[_i];
|
|
@@ -207,6 +208,33 @@ var SupportManager = /** @class */ (function () {
|
|
|
207
208
|
}
|
|
208
209
|
return promise;
|
|
209
210
|
};
|
|
211
|
+
SupportManager.prototype.callMethodInternal = function (method) {
|
|
212
|
+
var methodData = [];
|
|
213
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
214
|
+
methodData[_i - 1] = arguments[_i];
|
|
215
|
+
}
|
|
216
|
+
var _a;
|
|
217
|
+
var that = this;
|
|
218
|
+
if (!that._mainServer.getMethodManager()._methods[method]) {
|
|
219
|
+
console.log('No Method: ' + method);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._mainServer.getMethodManager()._methods[method].skipValidation) {
|
|
223
|
+
if (!that._mainServer.getMethodManager()._methods[method].check) {
|
|
224
|
+
console.error('No Check Function For Method ' + method);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
else if (!that._mainServer.getMethodManager()._methods[method].check._schema) {
|
|
228
|
+
console.error('No Check Schema For Method ' + method);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
var promise = (_a = that._mainServer.getMethodManager()._methods[method].function).call.apply(_a, [Object.assign({}, that, method_manager_1.MethodManager.prototype)].concat(methodData));
|
|
233
|
+
if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
|
|
234
|
+
promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
|
|
235
|
+
}
|
|
236
|
+
return promise;
|
|
237
|
+
};
|
|
210
238
|
SupportManager.prototype.sendWS = function (ws, method, methodData, data) {
|
|
211
239
|
this._sendQueue.splice(0, 0, {
|
|
212
240
|
id_ws: ws['id_socket'],
|
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ function loadSupportCronJobMethods(methodManager) {
|
|
|
59
59
|
count = 0;
|
|
60
60
|
interval = setInterval(function () {
|
|
61
61
|
var updateChunk = users.slice(count * 10, Math.min(users.length, (count + 1) * 10));
|
|
62
|
-
_this.
|
|
62
|
+
_this.callSupportMethodInternal.call(_this, 'updateClientUserChunk', updateChunk);
|
|
63
63
|
count++;
|
|
64
64
|
if (count * 10 > users.length) {
|
|
65
65
|
clearInterval(interval);
|