$(gateway).bind("onmotd", front.onMOTD);
$(gateway).bind("onoptions", front.onOptions);
$(gateway).bind("onconnect", front.onConnect);
+ $(gateway).bind("onconnect_fail", front.onConnectFail);
$(gateway).bind("ondisconnect", front.onDisconnect);
$(gateway).bind("onnick", front.onNick);
$(gateway).bind("onuserlist", front.onUserList);
front.tabviews.server.addMsg(null, ' ', '=== Failed to connect :(', 'status');
}
},
+ onConnectFail: function (e, data) {
+ var reason = (typeof data.reason === 'string') ? data.reason : '';
+ front.tabviews.server.addMsg(null, '', 'There\'s a problem connecting! (' + reason + ')', 'error');
+ },
onDisconnect: function (e, data) {
var tab;
for (tab in front.tabviews) {
if (typeof gateway.kiwi_server !== 'undefined') {
gateway.socket = io.connect(kiwi_server, {'max reconnection attempts': 3});
gateway.socket.of('/kiwi').on('connect_failed', function (reason) {
+ // TODO: When does this even actually get fired? I can't find a case! ~Darren
console.debug('Unable to connect Socket.IO', reason);
- front.tabviews.server.addMsg(null, ' ', 'Unable to connect to Kiwi IRC.\n' + reason, 'error');
+ //front.tabviews.server.addMsg(null, ' ', 'Unable to connect to Kiwi IRC.\n' + reason, 'error');
gateway.socket.disconnect();
- $(gateway).trigger("ondisconnect", {});
+ $(gateway).trigger("onconnect_fail", {reason: reason});
gateway.sendData = function () {};
}).on('error', function (e) {
+ $(gateway).trigger("onconnect_fail", {});
console.debug(e);
+ console.log(e);
});
gateway.socket.on('connect', function () {
+ console.log('connect event');
gateway.sendData = function (data, callback) {
gateway.socket.emit('message', {sid: this.session_id, data: $.toJSON(data)}, callback);
};
gateway.socket.emit('irc connect', gateway.nick, host, port, ssl, callback);
});
gateway.socket.on('too_many_connections', function () {
- front.tabviews.server.addMsg(null, ' ', 'Unable to connect to Kiwi IRC.\nYour IP address has too many connections to Kiwi IRC', 'error');
+ $(gateway).trigger("onconnect_fail", {reason: 'too_many_connections'});
});
}
},