Created
July 26, 2010 13:12
-
-
Save grenzr/490521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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