websocketError.apply(that, arguments);
});
- global.plugins.emit('client:connected', {client:this});
+ global.modules.emit('client:connected', {client:this});
};
util.inherits(Client, events.EventEmitter);
data.args = args;\r
data.client = null;\r
\r
- global.plugins.emit('client:commands:msg', data);\r
+ global.modules.emit('client:commands:msg', data);\r
\r
if (args.target && (args.msg)) {\r
// TODO: Enable plugin support here again\r
WebListener = require('./weblistener.js'),
config = require('./configuration.js'),
rehash = require('./rehash.js'),
- plugins = require('./plugins');
+ modules = require('./modules.js');
// 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');
// 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();
-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
};
- // 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;
}
}
- 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();
};
module.exports = {
// Objects
- Plugin: Plugin,
+ Module: Module,
Publisher: Publisher,
// Methods
-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