Skip to content

Commit

Permalink
only call events handlers for the current session
Browse files Browse the repository at this point in the history
  • Loading branch information
Floby committed Jan 3, 2013
1 parent 50e95c8 commit 8f86c30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/Session.js
Expand Up @@ -221,5 +221,14 @@ Session.prototype.getPlayer = function getPlayer() {
return this._player;
};

/**
* override event emitter method in order to attach callbacks to a specific session
* @override EventEmitter.addListener
*/
Session.prototype.addListener = function addListener(event, listener) {
EventEmitter.prototype.addListener.call(this, event, sessionCallback(this, listener));
};
Session.prototype.on = Session.prototype.addListener

// exports this Class
module.exports = Session;
2 changes: 1 addition & 1 deletion test/test-010-session02-login.js
Expand Up @@ -18,7 +18,7 @@ exports.testLoginIsSucessful = function(test) {
});
session.login(cred.login, cred.password);
console.log('trying to login, this may take a while');
session.once('login', function(err) {
session.on('login', function(err) {
if(err) test.done(err);
test.ok(session.isLoggedIn(), 'session should now it is now logged in');
session.logout(function() {
Expand Down

0 comments on commit 8f86c30

Please sign in to comment.