comparison lightstring.js @ 85:d9804e206393

Fix Safari/iOS support.
author Sonny Piers <sonny.piers@gmail.com>
date Wed, 08 Feb 2012 17:44:06 +0100
parents 2290321f5c8b
children 55548845b177
comparison
equal deleted inserted replaced
84:7f4e43d6cb15 85:d9804e206393
149 if (!this.jid.bare) 149 if (!this.jid.bare)
150 return; //TODO: error 150 return; //TODO: error
151 if (!this.service) 151 if (!this.service)
152 return; //TODO: error 152 return; //TODO: error
153 153
154 if (typeof(WebSocket) === "function") { 154 // Standard
155 if (typeof(WebSocket) === 'function')
155 this.socket = new WebSocket(this.service, 'xmpp'); 156 this.socket = new WebSocket(this.service, 'xmpp');
156 } 157 // Safari
157 else if (typeof(MozWebSocket) === "function") { 158 else if (typeof(WebSocket) === 'object')
159 this.socket = new WebSocket(this.service);
160 // Old Gecko
161 else if (typeof(MozWebSocket) === 'function') {
158 this.socket = new MozWebSocket(this.service, 'xmpp'); 162 this.socket = new MozWebSocket(this.service, 'xmpp');
159 } 163 }
164 // No known WebSocket support
160 else { 165 else {
161 return; //TODO: error 166 return; //TODO: error
162 } 167 }
163 168
164 var Conn = this; 169 var Conn = this;
165 this.socket.addEventListener('open', function() { 170 this.socket.addEventListener('open', function() {
166 if (this.protocol !== 'xmpp') 171 //FIXME: Opera/Safari WebSocket implementation doesn't support sub-protocol mechanism.
167 return; //TODO: error 172 //if (this.protocol !== 'xmpp')
173 //return; //TODO: error
168 174
169 var stream = Lightstring.stanzas.stream.open(Conn.jid.domain); 175 var stream = Lightstring.stanzas.stream.open(Conn.jid.domain);
170 //FIXME: Use Lightstring.Connection.send (problem with parsing steam); 176 //FIXME: Use Lightstring.Connection.send (problem with parsing steam);
171 Conn.socket.send(stream); 177 Conn.socket.send(stream);
172 var stanza = { 178 var stanza = {