# HG changeset patch # User Sonny Piers # Date 1326729340 -3600 # Node ID 6707f450549e8c57197e3f2ab069f2d9b0b4df32 # Parent 521962f107431d9d1f7f769a943f63c685eadea8 fix several problems diff --git a/lightstring.js b/lightstring.js --- a/lightstring.js +++ b/lightstring.js @@ -120,7 +120,7 @@ Lightstring.Connection = function(aServi var that = this; this.socket.addEventListener('open', function() { if (this.protocol !== 'xmpp') - throw 'Lightstring: The server located at '+ that.service + ' is not XMPP aware.'; + console.error('Lightstring: The server located at '+ that.service + ' doesn\'t seems to be XMPP aware.'); var stream = Lightstring.stanza.stream.open(that.host); @@ -159,7 +159,8 @@ Lightstring.Connection = function(aServi var str = this.dom2xml(elm); } else { - that.emit('error', 'Unsupported data type.'); + this.emit('error', 'Unsupported data type.'); + return; } @@ -173,7 +174,7 @@ Lightstring.Connection = function(aServi this.on(elm.getAttribute('id'), aCallback); } else if (aCallback) { - that.emit('warning', 'Callback can\'t be called with non-iq stanza.'); + this.emit('warning', 'Callback can\'t be called with non-iq stanza.'); } @@ -277,7 +278,7 @@ Lightstring.Connection = function(aServi }); this.on('success', function(stanza, that) { that.send( - "" @@ -324,7 +325,7 @@ Lightstring.Connection = function(aServi } } - var digest_uri = 'xmpp/' + that.domain; + var digest_uri = 'xmpp/' + that.host; if (host !== null) { digest_uri = digest_uri + '/' + host; } diff --git a/plugins.js b/plugins.js --- a/plugins.js +++ b/plugins.js @@ -16,6 +16,19 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +//////////// +//Presence// http://xmpp.org/rfcs/rfc6121.html#presence +//////////// +Lightstring.stanza.presence = function(aPriority) { + if(aPriority) + return ""+aPriority+""; + else + return ""; +}; +Lightstring.presence = function(aConnection, aPriority) { + aConnection.send(Lightstring.stanza.presence(aPriority)); +}; + ////////// //Roster// //////////