Pass callback to state.connect, fix vars
authorJack Allnutt <m2ys4u@gmail.com>
Thu, 24 Jan 2013 01:23:36 +0000 (01:23 +0000)
committerDarren <darren@darrenwhitlen.com>
Thu, 31 Jan 2013 14:58:42 +0000 (14:58 +0000)
server/client.js
server/irc/commands.js
server/irc/connection.js
server/irc/state.js

index ad343f72a26b115ad237a5009875f43c42adfc22..ddcb31249f5f91fb8a47b0f959a43e661cb74000 100755 (executable)
@@ -121,7 +121,8 @@ function kiwiCommand(command, callback) {
                         global.config.restrict_server_ssl,
                         command.nick,
                         {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
-                        global.config.restrict_server_password);
+                        global.config.restrict_server_password,
+                        callback);
 
                 } else {
                     this.state.connect(
@@ -130,7 +131,8 @@ function kiwiCommand(command, callback) {
                         command.ssl,
                         command.nick,
                         {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
-                        command.password);
+                        command.password,
+                        callback);
                 }
             } else {
                 return callback('Hostname, port and nickname must be specified');
index 452e959835dee0db1f7affdbbe108d38b78239f8..3903f320a78f6e40db0da4f9f27e1f0ec765df37 100644 (file)
@@ -416,7 +416,7 @@ var listeners = {
                 hostname: command.hostname,
                 channel: command.params[0],
                 msg: command.trailing
-            );
+            });
         }
     },
     'CAP': function (command) {
index 01d4743217bcdd8ba15c8e02c837ff5bb8a933f5..0d927c22ab6861639c07596583c6f2c1598e9791 100644 (file)
@@ -5,7 +5,7 @@ var net     = require('net'),
     _       = require('lodash');
 
 
-var IrcConnection = function (hostname, port, ssl, nick, user, pass) {
+var IrcConnection = function (hostname, port, ssl, nick, user, pass, state) {
     var that = this;
     events.EventEmitter.call(this);
     
@@ -23,6 +23,9 @@ var IrcConnection = function (hostname, port, ssl, nick, user, pass) {
     this.user = user;  // Contains users real hostname and address
     this.username = this.nick.replace(/[^0-9a-zA-Z\-_.]/, '');
     this.password = pass;
+    
+    // State object
+    this.state = state;
 
     // IRC connection information
     this.irc_host = {hostname: hostname, port: port};
index df1ba056e754fbb2db8982296d61237a1fac1c12..768e62bbaa0ec2bde65f29ed096cb25e183f0a25 100755 (executable)
@@ -1,5 +1,7 @@
-var util = require('util'),
-    IrcConnection = require('./connection.js');
+var util            = require('util'),
+    events          = require('events'),
+    _               = require('lodash'),
+    IrcConnection   = require('./connection.js').IrcConnection;
 
 var State = function (client, save_state) {
     events.EventEmitter.call(this);
@@ -36,18 +38,20 @@ State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callb
             global.config.restrict_server,
             global.config.restrict_server_port,
             global.config.restrict_server_ssl,
-            command.nick,
+            nick,
             user,
-            global.config.restrict_server_password);
+            global.config.restrict_server_password,
+            this);
 
     } else {
         con = new IrcConnection(
-            command.hostname,
-            command.port,
-            command.ssl,
-            command.nick,
+            hostname,
+            port,
+            ssl,
+            nick,
             user,
-            command.password);
+            pass,
+            this);
     }
     
     con_num = this.next_connection++;
@@ -61,7 +65,7 @@ State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callb
     });
     
     con.on('error', function (err) {
-        console.log('irc_connection error (' + command.hostname + '):', err);
+        console.log('irc_connection error (' + hostname + '):', err);
         return callback(err.code, {server: con_num, error: err});
     });