Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events subsystem #114

Merged
merged 8 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Spaces to tabs, to match upstream convention
  • Loading branch information
snazzware committed Jun 11, 2017
commit 06e84eee94914cffbc1a04271b896f5ab5d59350
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ node_modules/
mods/northern_bloc.hjson
mods/suprapi/*
mods/suprapi

.editor-settings
2 changes: 1 addition & 1 deletion core/bbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function main() {
}
],
function complete(err) {
events.registerModules();
events.registerModules();

// note this is escaped:
fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => {
Expand Down
4 changes: 2 additions & 2 deletions core/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ function connectEntry(client, nextMenu) {
//
displayBanner(term);

// fire event
events.emit('codes.l33t.enigma.system.term_detected', {'client': client});
// fire event
events.emit('codes.l33t.enigma.system.term_detected', {'client': client});

setTimeout( () => {
return client.menuStack.goto(nextMenu);
Expand Down
18 changes: 9 additions & 9 deletions core/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
'use strict';

const Config = require('./config.js');
const fs = require('fs');
const path = require('path');
const events = require('events');
const logger = require('./logger.js');
const fs = require('fs');
const path = require('path');
const events = require('events');
const logger = require('./logger.js');

var eventEmitter = new events.EventEmitter();

Expand All @@ -18,10 +18,10 @@ var self = module.exports = {
logger.log.debug("Register listener for "+eventName);
eventEmitter.on(eventName, listener);
},
remove: function(eventName, listener) {
logger.log.debug("Remove listener for "+eventName);
eventEmitter.removeListener(eventName, listener);
},
remove: function(eventName, listener) {
logger.log.debug("Remove listener for "+eventName);
eventEmitter.removeListener(eventName, listener);
},
registerModules: function() {
var mods = fs.readdirSync(Config.config.paths.mods);

Expand All @@ -32,7 +32,7 @@ var self = module.exports = {
}
if (fs.existsSync(modPath)) {
var module = require(modPath);

if (module.registerEvents !== undefined) {
logger.log.debug(modPath+" calling registerEvents function");
module.registerEvents();
Expand Down