mysql-live
Version:
Brings the server.publish and client.subscribe for live updates on mysql database. The only one Live Collections.
32 lines (31 loc) • 1.26 kB
JavaScript
var node_mysql_wrapper_1 = require("node-mysql-wrapper");
var MethodStore = (function () {
function MethodStore(handler) {
this.handler = handler;
this.registedMethods = {};
}
MethodStore.prototype.registerMethods = function (methodsObj) {
var _this = this;
node_mysql_wrapper_1.Helper.forEachKey(methodsObj, function (methodName) {
_this.registedMethods[methodName] = methodsObj[methodName];
});
};
MethodStore.prototype.callMethod = function (socket, methodName, methodsArguments, cb) {
if (cb)
methodsArguments.push(cb);
var _context = {};
_context["socket"] = socket;
_context["passport"] = this.handler.passport.getPassport(socket);
_context["isServer"] = false;
_context["isClient"] = true;
this.registedMethods[methodName].apply(_context, methodsArguments);
};
MethodStore.prototype.callMethodFromServer = function (methodName, methodsArguments) {
var _context = {};
_context["isServer"] = true;
_context["isClient"] = false;
return this.registedMethods[methodName].apply(_context, methodsArguments);
};
return MethodStore;
})();
exports.MethodStore = MethodStore;