Merge pull request #480 from M2Ys4U/config_commandline
[KiwiIRC.git] / server / client.js
index d2d76f05c3d0968f926b7920153f9af9235ab398..d41dc52e3db96568ccc86567c3fa6f87727bab82 100755 (executable)
@@ -16,7 +16,7 @@ var Client = function (websocket) {
     this.rpc = new WebsocketRpc(this.websocket);
 
     // Clients address
-    this.real_address = this.websocket.kiwi.real_address;
+    this.real_address = this.websocket.meta.real_address;
 
     // A hash to identify this client instance
     this.hash = crypto.createHash('sha256')
@@ -49,6 +49,9 @@ var Client = function (websocket) {
     });
 
     this.disposed = false;
+
+    // Let the client know it's finished connecting
+    this.sendKiwiCommand('connected');
 };
 util.inherits(Client, events.EventEmitter);
 
@@ -78,7 +81,8 @@ Client.prototype.dispose = function () {
 };
 
 function handleClientMessage(msg, callback) {
-    var server;
+    var that = this,
+        server;
 
     // Make sure we have a server number specified
     if ((msg.server === null) || (typeof msg.server !== 'number')) {
@@ -102,7 +106,13 @@ function handleClientMessage(msg, callback) {
     }
 
     // Run the client command
-    this.client_commands.run(msg.data.method, msg.data.args, server, callback);
+    global.modules.emit('client command', {
+        command: msg.data,
+        server: server
+    })
+    .done(function() {
+        that.client_commands.run(msg.data.method, msg.data.args, server, callback);
+    });
 }
 
 
@@ -131,7 +141,7 @@ function kiwiCommand(command, callback) {
                         global.config.restrict_server_ssl :
                         command.ssl),
                     command.nick,
-                    {hostname: this.websocket.kiwi.revdns, address: this.websocket.kiwi.real_address},
+                    {hostname: this.websocket.meta.revdns, address: this.websocket.meta.real_address},
                     options,
                     callback);
             } else {