changeset 6:b7a582a2b32c

add the sub-protocol (xmpp) negociation
author Sonny Piers <sonny.piers@gmail.com>
date Sun, 15 Jan 2012 01:01:59 +0100
parents 62c17284f3a1
children 715726598b23
files lightstring.js
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lightstring.js
+++ b/lightstring.js
@@ -58,14 +58,16 @@ Lightstring.Connection = function (aServ
 
     //"Bug 695635 - tracking bug: unprefix WebSockets" https://bugzil.la/695635
     try {
-      this.socket = new WebSocket(this.service);
+      this.socket = new WebSocket(this.service, 'xmpp');
     }
     catch(error) {
-      this.socket = new MozWebSocket(this.service);
+      this.socket = new MozWebSocket(this.service, 'xmpp');
     }
 
     var that = this;
     this.socket.addEventListener('open', function() {
+      if(this.protocol !== 'xmpp')
+        throw "Lightstring: The server located at "+that.service+" is not XMPP aware.";
       var stream =
         "<stream:stream to='"+that.domain+"'\
                         xmlns='jabber:client'\