Fixed merge fail

This commit is contained in:
Arnout Kazemier
2011-08-29 21:32:44 +02:00
parent 70d45aa8a9
commit 67f399263a

View File

@@ -1,196 +0,0 @@
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
(function (exports, io) {
/**
* Expose constructor.
*/
exports.websocket = WS;
/**
* Detect WebSocket implementation.
*/
function detectWebSocket () {
// if node
return require('websocket-client').WebSocket;
// end node
if (typeof window != 'undefined') {
return window.WebSocket || window.MozWebSocket;
}
}
/**
* The WebSocket transport uses the HTML5 WebSocket API to establish an
* persistent connection with the Socket.IO server. This transport will also
* be inherited by the FlashSocket fallback as it provides a API compatible
* polyfill for the WebSockets.
*
* @constructor
* @extends {io.Transport}
* @api public
*/
function WS (socket) {
io.Transport.apply(this, arguments);
};
/**
* Inherits from Transport.
*/
io.util.inherit(WS, io.Transport);
/**
* Transport name
*
* @api public
*/
WS.prototype.name = 'websocket';
/**
* Initializes a new `WebSocket` connection with the Socket.IO server. We attach
* all the appropriate listeners to handle the responses from the server.
*
* @returns {Transport}
* @api public
*/
WS.prototype.open = function () {
<<<<<<< HEAD
var Socket = 'MozWebSocket' in window ? MozWebSocket : WebSocket
, self = this;
this.websocket = new Socket(this.prepareUrl());
=======
var self = this
, query = io.util.query(this.socket.options.query);
this.websocket = new (detectWebSocket())(this.prepareUrl() + query);
>>>>>>> 62feaa3ba8455169c37f2ba672beb389288de4f3
this.websocket.onopen = function () {
self.onOpen();
self.socket.setBuffer(false);
};
this.websocket.onmessage = function (ev) {
self.onData(ev.data);
};
this.websocket.onclose = function () {
self.onClose();
self.socket.setBuffer(true);
};
this.websocket.onerror = function (e) {
self.onError(e);
};
return this;
};
/**
* Send a message to the Socket.IO server. The message will automatically be
* encoded in the correct message format.
*
* @returns {Transport}
* @api public
*/
WS.prototype.send = function (data) {
this.websocket.send(data);
return this;
};
/**
* Payload
*
* @api private
*/
WS.prototype.payload = function (arr) {
for (var i = 0, l = arr.length; i < l; i++) {
this.packet(arr[i]);
}
return this;
};
/**
* Disconnect the established `WebSocket` connection.
*
* @returns {Transport}
* @api public
*/
WS.prototype.close = function () {
this.websocket.close();
return this;
};
/**
* Handle the errors that `WebSocket` might be giving when we
* are attempting to connect or send messages.
*
* @param {Error} e The error.
* @api private
*/
WS.prototype.onError = function (e) {
this.socket.onError(e);
};
/**
* Returns the appropriate scheme for the URI generation.
*
* @api private
*/
WS.prototype.scheme = function () {
return this.socket.options.secure ? 'wss' : 'ws';
};
/**
* Checks if the browser has support for native `WebSockets` and that
* it's not the polyfill created for the FlashSocket transport.
*
* @return {Boolean}
* @api public
*/
WS.check = function () {
<<<<<<< HEAD
return ('WebSocket' in window && !('__addTask' in WebSocket))
|| 'MozWebSocket' in window;
=======
var WebSocket = detectWebSocket();
return WebSocket && !WebSocket.__addTask;
>>>>>>> 62feaa3ba8455169c37f2ba672beb389288de4f3
};
/**
* Check if the `WebSocket` transport support cross domain communications.
*
* @returns {Boolean}
* @api public
*/
WS.xdomainCheck = function () {
return true;
};
/**
* Add the transport to your public io.transports array.
*
* @api private
*/
io.transports.push('websocket');
})(
'undefined' != typeof io ? io.Transport : module.exports
, 'undefined' != typeof io ? io : module.parent.exports
);