Permalink
Browse files

Fixed #28. Updated to socket.io 0.9.

  • Loading branch information...
1 parent ae2856a commit 637619d66772478044b534ed599a0e684ee7b27d @mrjoes committed Feb 28, 2012
Showing with 21 additions and 18 deletions.
  1. +18 −15 examples/socket.io.js
  2. +1 −1 tornadio2/conn.py
  3. +2 −2 tornadio2/session.py
View
33 examples/socket.io.js
@@ -1,4 +1,4 @@
-/*! Socket.IO.js build:0.8.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
+/*! Socket.IO.js build:0.9.0, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
/**
* socket.io
@@ -22,7 +22,7 @@
* @api public
*/
- io.version = '0.8.6';
+ io.version = '0.9.0';
/**
* Protocol implemented.
@@ -102,7 +102,6 @@
};
})('object' === typeof module ? module.exports : (this.io = {}), this);
-
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -210,7 +209,7 @@
for (; i < l; ++i) {
kv = params[i].split('=');
if (kv[0]) {
- query[kv[0]] = decodeURIComponent(kv[1]);
+ query[kv[0]] = kv[1];
}
}
@@ -399,10 +398,7 @@
*/
util.indexOf = function (arr, o, i) {
- if (Array.prototype.indexOf) {
- return Array.prototype.indexOf.call(arr, o, i);
- }
-
+
for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0;
i < j && arr[i] !== o; i++) {}
@@ -1273,7 +1269,7 @@
// If the connection in currently open (or in a reopening state) reset the close
// timeout since we have just received data. This check is necessary so
// that we don't reset the timeout on an explicitly disconnected connection.
- if (this.connected || this.connecting || this.reconnecting) {
+ if (this.socket.connected || this.socket.connecting || this.socket.reconnecting) {
this.setCloseTimeout();
}
@@ -1465,7 +1461,6 @@
'undefined' != typeof io ? io : module.exports
, 'undefined' != typeof io ? io : module.parent.exports
);
-
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -1616,6 +1611,7 @@
var xhr = io.util.request();
xhr.open('GET', url, true);
+ xhr.withCredentials = true;
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
xhr.onreadystatechange = empty;
@@ -1869,7 +1865,7 @@
Socket.prototype.onError = function (err) {
if (err && err.advice) {
- if (err.advice === 'reconnect' && this.connected) {
+ if (this.options.reconnect && err.advice === 'reconnect' && this.connected) {
this.disconnect();
this.reconnect();
}
@@ -1928,6 +1924,8 @@
self.publish('reconnect', self.transport.name, self.reconnectionAttempts);
}
+ clearTimeout(self.reconnectionTimer);
+
self.removeListener('connect_failed', maybeReconnect);
self.removeListener('connect', maybeReconnect);
@@ -3166,7 +3164,6 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
, 'undefined' != typeof io ? io : module.parent.exports
, this
);
-
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -3304,7 +3301,7 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
*/
HTMLFile.check = function () {
- if ('ActiveXObject' in window){
+ if (typeof window != "undefined" && 'ActiveXObject' in window){
try {
var a = new ActiveXObject('htmlfile');
return a && io.Transport.XHR.check();
@@ -3428,14 +3425,20 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
function onload () {
this.onload = empty;
+ this.onerror = empty;
self.onData(this.responseText);
self.get();
};
+ function onerror () {
+ self.onClose();
+ };
+
this.xhr = this.request();
if (global.XDomainRequest && this.xhr instanceof XDomainRequest) {
- this.xhr.onload = this.xhr.onerror = onload;
+ this.xhr.onload = onload;
+ this.xhr.onerror = onerror;
} else {
this.xhr.onreadystatechange = stateChange;
}
@@ -3453,7 +3456,7 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
io.Transport.XHR.prototype.onClose.call(this);
if (this.xhr) {
- this.xhr.onreadystatechange = this.xhr.onload = empty;
+ this.xhr.onreadystatechange = this.xhr.onload = this.xhr.onerror = empty;
try {
this.xhr.abort();
} catch(e){}
View
2 tornadio2/conn.py
@@ -151,7 +151,7 @@ def on_message(self, message):
"""Default on_message handler. Must be overridden in your application"""
raise NotImplementedError()
- def on_event(self, name, *args, **kwargs):
+ def on_event(self, name, args=[], kwargs=dict()):
"""Default on_event handler.
By default, it uses decorator-based approach to handle events,
View
4 tornadio2/session.py
@@ -401,9 +401,9 @@ def raw_message(self, msg):
# Fix for the http://bugs.python.org/issue4978 for older Python versions
str_args = dict((str(x), y) for x, y in args[0].iteritems())
- ack_response = conn.on_event(event['name'], **str_args)
+ ack_response = conn.on_event(event['name'], kwargs=str_args)
else:
- ack_response = conn.on_event(event['name'], *args)
+ ack_response = conn.on_event(event['name'], args=args)
if msg_id:
if msg_id.endswith('+'):

0 comments on commit 637619d

Please sign in to comment.