var funcs = {\r
kiwi: 'kiwi', raw: 'raw', kick: 'kick', topic: 'topic',\r
part: 'part', join: 'join', action: 'action', ctcp: 'ctcp',\r
- notice: 'notice', msg: 'privmsg',\r
+ notice: 'notice', msg: 'privmsg', changeNick: 'changeNick',\r
get: 'get'\r
};\r
\r
_kiwi.gateway.set('kiwi_server', that.kiwi_server + '/kiwi');\r
_kiwi.gateway.set('nick', event.nick);\r
\r
- _kiwi.gateway.connect(event.server, event.port, event.ssl, event.password, function (error) {\r
+ _kiwi.gateway.connect(event.nick, event.server, event.port, event.ssl, event.password, function (error) {\r
if (error) {\r
kiwiServerNotFound();\r
}\r
// Some easier handler events\r
this.on('onmsg', function (event) {\r
var source,\r
- is_pm = (event.channel == that.get('nick'));\r
+ connection = _kiwi.app.connections.getByConnectionId(event.server),\r
+ is_pm = (event.channel == connection.get('nick'));\r
\r
source = is_pm ? event.nick : event.channel;\r
\r
\r
this.on('onaction', function (event) {\r
var source,\r
- is_pm = (event.channel == that.get('nick'));\r
+ connection = _kiwi.app.connections.getByConnectionId(event.server),\r
+ is_pm = (event.channel == cinnection.get('nick'));\r
\r
source = is_pm ? event.nick : event.channel;\r
\r
\r
/**\r
* Connects to the server\r
+ * @param {String} nick The nickname of the user to use on the network\r
* @param {String} host The hostname or IP address of the IRC server to connect to\r
* @param {Number} port The port of the IRC server to connect to\r
* @param {Boolean} ssl Whether or not to connect to the IRC server using SSL\r
* @param {String} password The password to supply to the IRC server during registration\r
* @param {Function} callback A callback function to be invoked once Kiwi's server has connected to the IRC server\r
*/\r
- this.connect = function (host, port, ssl, password, callback) {\r
+ this.connect = function (nick, host, port, ssl, password, callback) {\r
var resource;\r
\r
// Work out the resource URL for socket.io\r
*/\r
this.socket.on('connect', function () {\r
that.newConnection({\r
- nick: that.get('nick'),\r
+ nick: nick,\r
host: host,\r
port: port,\r
ssl: ssl,\r
//console.log('gateway event', command, data);\r
\r
if (command !== undefined) {\r
- that.trigger('on' + command, data);\r
-\r
switch (command) {\r
case 'options':\r
$.each(data.options, function (name, value) {\r
that.set('cap', data.cap);\r
break;\r
\r
- case 'connect':\r
- that.set('nick', data.nick);\r
- break;\r
-\r
- case 'nick':\r
- if (data.nick === that.get('nick')) {\r
- that.set('nick', data.newnick);\r
- }\r
- break;\r
/*\r
case 'sync':\r
if (_kiwi.gateway.onSync && _kiwi.gateway.syncing) {\r
event_data: data\r
});\r
}\r
+\r
+ // Trigger the global events (Mainly legacy now)\r
+ that.trigger('on' + command, data);\r
};\r
\r
/**\r
\r
changeNick: function (event) {\r
var that = this;\r
- _kiwi.gateway.changeNick(this.$el.find('input').val(), function (err, val) {\r
+\r
+ event.preventDefault();\r
+\r
+ _kiwi.app.connections.active_connection.gateway.changeNick(this.$el.find('input').val(), function (err, val) {\r
that.close();\r
});\r
return false;\r
_kiwi.gateway.bind('onnick', function (event) {\r
$('.nick', that.$el).text(_kiwi.app.connections.active_connection.get('nick'));\r
});\r
- _kiwi.gateway.bind('onconnect', function (event) {\r
- $('.nick', that.$el).text(event.nick);\r
- });\r
\r
// Update our nick view as we flick between connections\r
_kiwi.app.connections.on('active', function(panel, connection) {\r