changeset 76:0b8e7ca19f83

Plugins init functions are now called with Lightstring.Connection scope.
author Sonny Piers <sonny.piers@gmail.com>
date Mon, 06 Feb 2012 18:02:02 +0100
parents 619f3ffa125a
children 7854e036a572
files lightstring.js plugins/disco.js
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lightstring.js
+++ b/lightstring.js
@@ -321,7 +321,7 @@ Lightstring.Connection.prototype = {
         this[name][method] = plugin.methods[method].bind(this);
 
       if (plugin.init)
-        plugin.init();
+        plugin.init.apply(this);
     }
   },
   /**
--- a/plugins/disco.js
+++ b/plugins/disco.js
@@ -131,7 +131,7 @@
       }
     },
     init: function() {
-      conn.on('iq/' + Lightstring.ns['disco#info'] + ':query', function(stanza) {
+      this.on('iq/' + Lightstring.ns['disco#info'] + ':query', function(stanza) {
         if (stanza.DOM.getAttributeNS(null, 'type') !== 'get')
           return false;
 
@@ -140,7 +140,7 @@
           var response = "<iq to='" + stanza.DOM.getAttributeNS(null, 'from') + "'" +
                             " id='" + stanza.DOM.getAttributeNS(null, 'id') + "'" +
                             " type='error'/>"; //TODO: precise the error.
-          conn.send(response);
+          this.send(response);
           return true;
         }
 
@@ -167,7 +167,7 @@
         res += "</query>" +
              "</iq>";
 
-        conn.send(res);
+        this.send(res);
         return true;
       });
     }