From: Darren Date: Tue, 20 Nov 2012 17:53:02 +0000 (+0000) Subject: Rename 'plugins' to 'modules' X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ae64bf07860700db33603000e21974bd67216199;p=KiwiIRC.git Rename 'plugins' to 'modules' --- diff --git a/server/client.js b/server/client.js index 60912be..6ffe38c 100755 --- a/server/client.js +++ b/server/client.js @@ -47,7 +47,7 @@ var Client = function (websocket) { websocketError.apply(that, arguments); }); - global.plugins.emit('client:connected', {client:this}); + global.modules.emit('client:connected', {client:this}); }; util.inherits(Client, events.EventEmitter); diff --git a/server/clientcommands.js b/server/clientcommands.js index 9118ba5..13b5243 100644 --- a/server/clientcommands.js +++ b/server/clientcommands.js @@ -26,7 +26,7 @@ var listeners = { data.args = args; data.client = null; - global.plugins.emit('client:commands:msg', data); + global.modules.emit('client:commands:msg', data); if (args.target && (args.msg)) { // TODO: Enable plugin support here again diff --git a/server/kiwi.js b/server/kiwi.js index fafc5cf..9e716a0 100755 --- a/server/kiwi.js +++ b/server/kiwi.js @@ -3,7 +3,7 @@ var fs = require('fs'), WebListener = require('./weblistener.js'), config = require('./configuration.js'), rehash = require('./rehash.js'), - plugins = require('./plugins'); + modules = require('./modules.js'); @@ -57,10 +57,10 @@ if ((!global.config.servers) || (global.config.servers.length < 1)) { // Create a plugin interface -global.plugins = new plugins.Publisher(); +global.modules = new modules.Publisher(); // Register as the active imterfac -plugins.registerPublisher(global.plugins); +modules.registerPublisher(global.modules); require('../server_modules/example.js'); diff --git a/server/plugins.js b/server/modules.js similarity index 76% rename from server/plugins.js rename to server/modules.js index cb94427..3961785 100644 --- a/server/plugins.js +++ b/server/modules.js @@ -8,7 +8,7 @@ var active_publisher; // Create a publisher to allow event subscribing function Publisher (obj) { - var EventPublisher = function pluginPublisher() {}; + var EventPublisher = function modulePublisher() {}; util.inherits(EventPublisher, events.EventEmitter); return new EventPublisher(); @@ -22,9 +22,9 @@ function registerPublisher (obj) { -function Plugin (plugin_name) { +function Module (module_name) { - // Holder for all the bound events by this plugin + // Holder for all the bound events by this module var bound_events = {}; // Handy function to be a little more consistant with EventEmitter @@ -33,25 +33,25 @@ function Plugin (plugin_name) { }; - // Keep track of this plugins events and bind + // Keep track of this modules events and bind this.subscribe = function (event_name, fn) { bound_events[event_name] = bound_events[event_name] || []; bound_events[event_name].push(fn); - global.plugins.on(event_name, fn); + global.modules.on(event_name, fn); }; - // Keep track of this plugins events and bind once + // Keep track of this modules events and bind once this.once = function (event_name, fn) { bound_events[event_name] = bound_events[event_name] || []; bound_events[event_name].push(fn); - global.plugins.once(event_name, fn); + global.modules.once(event_name, fn); }; - // Remove any events by this plugin only + // Remove any events by this module only this.unsubscribe = function (event_name, fn) { var idx; @@ -72,11 +72,11 @@ function Plugin (plugin_name) { } } - global.plugins.removeListener(event_name, fn); + global.modules.removeListener(event_name, fn); }; - // Clean up anything used by this plugin + // Clean up anything used by this module this.dispose = function () { this.unsubscribe(); }; @@ -86,7 +86,7 @@ function Plugin (plugin_name) { module.exports = { // Objects - Plugin: Plugin, + Module: Module, Publisher: Publisher, // Methods diff --git a/server_modules/example.js b/server_modules/example.js index 9fa30cf..df11360 100644 --- a/server_modules/example.js +++ b/server_modules/example.js @@ -1,14 +1,14 @@ -var kiwiPlugins = require('../server/plugins.js'); +var kiwiModules = require('../server/modules'); -var plugin = new kiwiPlugins.Plugin('Example Plugin'); +var module = new kiwiModules.Module('Example Module'); -plugin.subscribe('client:connected', function(data) { - console.log('Client connection:', data); +module.subscribe('client:connected', function(data) { + console.log('Client connection:', data); }); -plugin.subscribe('client:commands:msg', function(data) { - console.log('Client msg:', data.args.target, ': ', data.args.msg); - data.args.msg += ' - modified!'; +module.subscribe('client:commands:msg', function(data) { + console.log('Client msg:', data.args.target, ': ', data.args.msg); + data.args.msg += ' - modified!'; }); \ No newline at end of file