Fixed support for Node.JS running socket.io-client.

This commit is contained in:
Guillermo Rauch
2011-09-03 10:57:15 -07:00
parent fc53c5b2be
commit 7a863e6cc8

View File

@@ -51,9 +51,17 @@
*/
WS.prototype.open = function () {
var Socket = 'MozWebSocket' in window ? MozWebSocket : WebSocket
, query = io.util.query(this.socket.options.query)
, self = this;
var query = io.util.query(this.socket.options.query)
, self = this
, Socket
// if node
Socket = require('websocket-client').WebSocket;
// end node
if (!Socket) {
Socket = window.MozWebSocket || window.WebSocket;
}
this.websocket = new Socket(this.prepareUrl() + query);
@@ -143,6 +151,9 @@
*/
WS.check = function () {
// if node
return true;
// end node
return ('WebSocket' in window && !('__addTask' in WebSocket))
|| 'MozWebSocket' in window;
};