IrcConnection = require('./connection.js').IrcConnection;
var State = function (client, save_state) {
+ var that = this;
+
events.EventEmitter.call(this);
this.client = client;
this.save_state = save_state || false;
this.irc_connections = [];
this.next_connection = 0;
- this.client.on('disconnect', function () {
- if (!this.save_state) {
- _.each(this.irc_connections, function (irc_connection, i, cons) {
+ this.client.on('destroy', function () {
+ if (!that.save_state) {
+ _.each(that.irc_connections, function (irc_connection, i, cons) {
if (irc_connection) {
irc_connection.end('QUIT :' + (global.config.quit_message || ''));
irc_connection.dispose();
cons[i] = null;
+ console.log('killed irc_connection');
}
});
- this.dispose();
+ that.dispose();
}
});
};
\r
\r
IrcUser.prototype.dispose = function () {\r
- EventBinder.unbindIrcEvents('user:' + this.nick, this.irc_events);\r
+ EventBinder.unbindIrcEvents('user:' + this.nick, this.irc_events, this.irc_connection);\r
this.irc_connection = undefined;\r
};\r
\r