\r
this.socket.on('error', function (e) {\r
console.log("_kiwi.gateway.socket.on('error')", {reason: e});\r
+ if (that.connect_callback) {\r
+ that.connect_callback(e);\r
+ delete that.connect_callback;\r
+ }\r
+\r
that.trigger("connect_fail", {reason: e});\r
});\r
\r
this.newConnection = function(connection_info, callback_fn) {\r
var that = this;\r
\r
+ // If not connected, connect first then re-call this function\r
+ if (!this.isConnected()) {\r
+ this.connect(function(err) {\r
+ if (err) {\r
+ callback_fn(err);\r
+ return;\r
+ }\r
+\r
+ that.newConnection(connection_info, callback_fn);\r
+ });\r
+\r
+ return;\r
+ }\r
+\r
this.makeIrcConnection(connection_info, function(err, server_num) {\r
var connection;\r
\r
onMakeConnection: function(new_connection_event) {
- var that = this,
- transport_path = '',
- auto_connect_details = new_connection_event;
-
- this.view.networkConnecting();
-
- // If not connected already, connect then send the IRC connect info
- if (!_kiwi.gateway.isConnected()) {
- _kiwi.gateway.connect(function() {
- that.makeConnection(new_connection_event);
- });
-
- } else {
- this.makeConnection(new_connection_event);
- }
-
-
- },
-
-
- onKiwiServerNotFound: function() {
- this.view.showError();
- },
-
-
- makeConnection: function(new_connection_event) {
var that = this;
this.connect_details = new_connection_event;
+ this.view.networkConnecting();
+
_kiwi.gateway.newConnection({
nick: new_connection_event.nick,
host: new_connection_event.server,