comparison lightstring.js @ 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 029c12b8f048
children 24bc40461b2c
comparison
equal deleted inserted replaced
5:62c17284f3a1 6:b7a582a2b32c
56 if(!this.service) 56 if(!this.service)
57 throw "Lightstring: Connection.service is undefined."; 57 throw "Lightstring: Connection.service is undefined.";
58 58
59 //"Bug 695635 - tracking bug: unprefix WebSockets" https://bugzil.la/695635 59 //"Bug 695635 - tracking bug: unprefix WebSockets" https://bugzil.la/695635
60 try { 60 try {
61 this.socket = new WebSocket(this.service); 61 this.socket = new WebSocket(this.service, 'xmpp');
62 } 62 }
63 catch(error) { 63 catch(error) {
64 this.socket = new MozWebSocket(this.service); 64 this.socket = new MozWebSocket(this.service, 'xmpp');
65 } 65 }
66 66
67 var that = this; 67 var that = this;
68 this.socket.addEventListener('open', function() { 68 this.socket.addEventListener('open', function() {
69 if(this.protocol !== 'xmpp')
70 throw "Lightstring: The server located at "+that.service+" is not XMPP aware.";
69 var stream = 71 var stream =
70 "<stream:stream to='"+that.domain+"'\ 72 "<stream:stream to='"+that.domain+"'\
71 xmlns='jabber:client'\ 73 xmlns='jabber:client'\
72 xmlns:stream='http://etherx.jabber.org/streams'\ 74 xmlns:stream='http://etherx.jabber.org/streams'\
73 version='1.0'/>"; 75 version='1.0'/>";