1 _kiwi
.model
.NewConnection
= Backbone
.Collection
.extend({
2 initialize: function() {
3 this.view
= new _kiwi
.view
.ServerSelect();
5 this.view
.bind('server_connect', this.onMakeConnection
, this);
10 onMakeConnection: function(new_connection_event
) {
13 auto_connect_details
= new_connection_event
;
15 this.view
.networkConnecting();
18 // If we don't have socket.io loaded, load it before opening a new connection
20 // Path to get the socket.io transport code
21 transport_path
= _kiwi
.app
.kiwi_server
+ _kiwi
.app
.get('base_path') + '/transport/socket.io.js?ts='+(new Date().getTime());
23 $script(transport_path
, function() {
25 that
.onKiwiServerNotFound();
29 _kiwi
.gateway
.set('kiwi_server', _kiwi
.app
.kiwi_server
+ '/kiwi');
30 _kiwi
.gateway
.connect(function() {
31 that
.makeConnection(new_connection_event
);
36 this.makeConnection(new_connection_event
);
43 onKiwiServerNotFound: function() {
44 this.view
.showError();
48 makeConnection: function(new_connection_event
) {
51 _kiwi
.gateway
.newConnection({
52 nick
: new_connection_event
.nick
,
53 host
: new_connection_event
.server
,
54 port
: new_connection_event
.port
,
55 ssl
: new_connection_event
.ssl
,
56 password
: new_connection_event
.password
57 }, function(err
, network
) {
58 that
.onNewNetwork(err
, network
);
63 onNewNetwork: function(err
, network
) {
64 // Show the server panel if this is our first network
65 if (network
&& network
.get('connection_id') === 0) {
66 network
.panels
.server
.view
.show();