Permalink
Browse files

websocket:Improve send method

  • Loading branch information...
1 parent ef6d89b commit 60c61af68e578b2355f33d666a50af5e571dbf2a @xixixao xixixao committed Jan 19, 2013
Showing with 3 additions and 6 deletions.
  1. +3 −6 lib/transports/websocket.js
@@ -81,7 +81,8 @@ WebSocket.prototype.onData = function (data) {
* @param {Array} packets
* @api private
*/
-var isIOS;
+var isIOS = 'undefined' != typeof navigator
+ && /iPad|iPhone|iPod/i.test(navigator.userAgent)
WebSocket.prototype.send = function (data){
function send(packets){
for (var i = 0, l = packets.length; i < l; i++) {
@@ -96,11 +97,7 @@ WebSocket.prototype.send = function (data){
});
}
}
- // Due to a bug in the current iOS browser, we need to wrap the send in a
- // setTimeout, when they resume from sleeping the browser will crash if
- // we don't allow the browser time to detect the socket has been closed
- isIOS = (isIOS !== undefined) ? isIOS : 'undefined' != typeof navigator
- && /iPad|iPhone|iPod/i.test(navigator.userAgent)
+ // see https://github.com/LearnBoost/socket.io-client/pull/426
if (isIOS) {
var self = this;
setTimeout(function() {

0 comments on commit 60c61af

Please sign in to comment.