Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

only call events handlers for the current session

  • Loading branch information...
commit 8f86c308dbade08ae9a2b47df83477e608fd540f 1 parent 50e95c8
@Floby authored
Showing with 10 additions and 1 deletion.
  1. +9 −0 lib/Session.js
  2. +1 −1  test/test-010-session02-login.js
View
9 lib/Session.js
@@ -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;
View
2  test/test-010-session02-login.js
@@ -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() {
Please sign in to comment.
Something went wrong with that request. Please try again.