Skip to content

Instantly share code, notes, and snippets.

@grenzr
Created July 26, 2010 13:12
Show Gist options
  • Save grenzr/490521 to your computer and use it in GitHub Desktop.
Save grenzr/490521 to your computer and use it in GitHub Desktop.
var
sys = require("sys"),
flow = require("../vendor/flow"),
redis = require("../vendor/redis-client");
function log(what) {
sys.log("[ext:test] " + what);
}
exports.init_extension = function (options, context) {
log("initializing.");
var func_name = 'on_PUBLISH';
var handlers = our.dispatch._handlers;
var n = handlers.length;
for (var i=0; i<n; ++i) {
var handler = handlers[i];
if (handler.hasOwnProperty(func_name) &&
typeof handler[func_name] == "function") {
var oldPublish = handler[func_name];
handler[func_name] = function (client, request, callback) {
access = false; // or true - do your logic here :)
if (access) {
return oldPublish(client,request,callback);
} else {
client.respond(false);
process.nextTick(callback);
}
}
}
}
};
exports.deinit_extension = function (context, callback) {
log("deinitializing.");
process.nextTick(callback);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment