websocket.sendServerLine('NICK ' + nick);
websocket.sendServerLine('USER kiwi_' + nick.replace(/[^0-9a-zA-Z\-_.]/, '') + ' 0 0 :' + nick);
+ that.connected = true;
that.emit('connect');
});
};
});
ircSocket.on('error', function (e) {
+ that.connected = false;
that.emit('error', e);
+ that.destroySoon();
});
if (typeof callback === 'function') {
}
ircSocket.on('end', function () {
+ that.connected = false;
that.emit('disconnect', false);
});
ircSocket.on('close', function (had_error) {
+ that.connected = false;
that.emit('disconnect', had_error);
});
ircSocket.on('timeout', function () {
ircSocket.destroy();
+ that.connected = false;
that.emit('error', {message: 'Connection timed out'});
});
};
this.end = function (data, encoding, callback) {
+ that.connected = false;
ircSocket.end(data, encoding, callback);
};
this.websocketDisconnect = function (websocket) {
var con;
- if ((!websocket.sentQUIT) && (websocket.ircSocket)) {
+ if ((!websocket.sentQUIT) && (websocket.ircConnection.connected)) {
try {
- websocket.ircSocket.end('QUIT :' + kiwi.config.quit_message + '\r\n');
+ websocket.ircConnection.end('QUIT :' + kiwi.config.quit_message + '\r\n');
websocket.sentQUIT = true;
- websocket.ircSocket.destroySoon();
+ websocket.ircConnection.destroySoon();
} catch (e) {
}
}