smartsocket/dist/smartsocket.classes.socketfunction.js

37 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-08-07 16:59:39 +00:00
"use strict";
2016-08-09 21:37:25 +00:00
const plugins = require("./smartsocket.plugins");
2016-08-09 09:42:21 +00:00
;
// export classes
/**
2016-08-09 21:37:25 +00:00
* class that respresents a function that can be transparently called using a SocketConnection
2016-08-09 09:42:21 +00:00
*/
2016-08-07 16:59:39 +00:00
class SocketFunction {
2016-08-09 09:42:21 +00:00
/**
* the constructor for SocketFunction
*/
2016-08-07 16:59:39 +00:00
constructor(optionsArg) {
2016-08-09 21:37:25 +00:00
this.name = optionsArg.funcName;
this.func = optionsArg.funcDef;
this.roles = optionsArg.allowedRoles;
2016-08-08 16:20:00 +00:00
for (let socketRoleArg of this.roles) {
this._notifyRole(socketRoleArg);
}
2016-08-07 16:59:39 +00:00
}
;
2016-08-09 09:42:21 +00:00
/**
* notifies a role about access to this SocketFunction
*/
2016-08-08 16:20:00 +00:00
_notifyRole(socketRoleArg) {
socketRoleArg.addSocketFunction(this);
}
2016-08-09 09:42:21 +00:00
/**
* invokes the function of this SocketFunction
*/
invoke(dataArg) {
2016-08-09 21:37:25 +00:00
let done = plugins.q.defer();
return done.promise;
2016-08-08 16:20:00 +00:00
}
2016-08-09 09:42:21 +00:00
;
2016-08-07 16:59:39 +00:00
}
exports.SocketFunction = SocketFunction;
2016-08-09 21:37:25 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRmdW5jdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc29ja2V0ZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFrQmhELENBQUM7QUFVRixpQkFB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