8000 Fixed #28. Updated to socket.io 0.9. · pythonanywhere/tornadio2@637619d · GitHub
[go: up one dir, main page]

Skip to content

Commit 637619d

Browse files
committed
Fixed mrjoes#28. Updated to socket.io 0.9.
1 parent ae2856a commit 637619d

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

examples/socket.io.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Socket.IO.js build:0.8.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
1+
/*! Socket.IO.js build:0.9.0, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
22

33
/**
44
* socket.io
@@ -22,7 +22,7 @@
2222
* @api public
2323
*/
2424

25-
io.version = '0.8.6';
25+
io.version = '0.9.0';
2626

2727
/**
2828
* Protocol implemented.
@@ -102,7 +102,6 @@
102102
};
103103

104104
})('object' === typeof module ? module.exports : (this.io = {}), this);
105-
106105
/**
107106
* socket.io
108107
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -210,7 +209,7 @@
210209
for (; i < l; ++i) {
211210
kv = params[i].split('=');
212211
if (kv[0]) {
213-
query[kv[0]] = decodeURIComponent(kv[1]);
212+
query[kv[0]] = kv[1];
214213
}
215214
}
216215

@@ -399,10 +398,7 @@
399398
*/
400399

401400
util.indexOf = function (arr, o, i) {
402-
if (Array.prototype.indexOf) {
403-
return Array.prototype.indexOf.call(arr, o, i);
404-
}
405-
401+
406402
for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0;
407403
i < j && arr[i] !== o; i++) {}
408404

@@ -1273,7 +1269,7 @@
12731269
// If the connection in currently open (or in a reopening state) reset the close
12741270
// timeout since we have just received data. This check is necessary so
12751271
// that we don't reset the timeout on an explicitly disconnected connection.
1276-
if (this.connected || this.connecting || this.reconnecting) {
1272+
if (this.socket.connected || this.socket.connecting || this.socket.reconnecting) {
12771273
this.setCloseTimeout();
12781274
}
12791275

@@ -1465,7 +1461,6 @@
14651461
'undefined' != typeof io ? io : module.exports
14661462
, 'undefined' != typeof io ? io : module.parent.exports
14671463
);
1468-
14691464
/**
14701465
* socket.io
14711466
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -1616,6 +1611,7 @@
16161611
var xhr = io.util.request();
16171612

16181613
xhr.open('GET', url, true);
1614+
xhr.withCredentials = true;
16191615
xhr.onreadystatechange = function () {
16201616
if (xhr.readyState == 4) {
16211617
xhr.onreadystatechange = empty;
@@ -1869,7 +1865,7 @@
18691865

18701866
Socket.prototype.onError = function (err) {
18711867
if (err && err.advice) {
1872-
if (err.advice === 'reconnect' && this.connected) {
1868+
if (this.options.reconnect && err.advice === 'reconnect' && this.connected) {
18731869
this.disconnect();
18741870
this.reconnect();
18751871
}
@@ -1928,6 +1924,8 @@
19281924
self.publish('reconnect', self.transport.name, self.reconnectionAttempts);
19291925
}
19301926

1927+
clearTimeout(self.reconnectionTimer);
1928+
19311929
self.removeListener('connect_failed', maybeReconnect);
19321930
self.removeListener('connect', maybeReconnect);
19331931

@@ -3166,7 +3164,6 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
31663164
, 'undefined' != typeof io ? io : module.parent.exports
31673165
, this
31683166
);
3169-
31703167
/**
31713168
* socket.io
31723169
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -3304,7 +3301,7 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
33043301
*/
33053302

33063303
HTMLFile.check = function () {
3307-
if ('ActiveXObject' in window){
3304+
if (typeof window != "undefined" && 'ActiveXObject' in window){
33083305
try {
33093306
var a = new ActiveXObject('htmlfile');
33103307
return a && io.Transport.XHR.check();
@@ -3428,14 +3425,20 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
34283425

34293426
function onload () {
34303427
this.onload = empty;
3428+
this.onerror = empty;
34313429
self.onData(this.responseText);
34323430
self.get();
34333431
};
34343432

3433+
function onerror () {
3434+
self.onClose();
3435+
};
3436+
34353437
this.xhr = this.request();
34363438

34373439
if (global.XDomainRequest && this.xhr instanceof XDomainRequest) {
3438-
this.xhr.onload = this.xhr.onerror = onload;
3440+
this.xhr.onload = onload;
3441+
this.xhr.onerror = onerror;
34393442
} else {
34403443
this.xhr.onreadystatechange = stateChange;
34413444
}
@@ -3453,7 +3456,7 @@ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="Sho
34533456
io.Transport.XHR.prototype.onClose.call(this);
34543457

34553458
if (this.xhr) {
3456-
this.xhr.onreadystatechange = this.xhr.onload = empty;
3459+
this.xhr.onreadystatechange = this.xhr.onload = this.xhr.onerror = empty;
34573460
try {
34583461
this.xhr.abort();
34593462
} catch(e){}

tornadio2/conn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def on_message(self, message):
151151
"""Default on_message handler. Must be overridden in your application"""
152152
raise NotImplementedError()
153153

154-
def on_event(self, name, *args, **kwargs):
154+
def on_event(self, name, args=[], kwargs=dict()):
155155
"""Default on_event handler.
156156
157157
By default, it uses decorator-based approach to handle events,

tornadio2/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ def raw_message(self, msg):
401401
# Fix for the http://bugs.python.org/issue4978 for older Python versions
402402
str_args = dict((str(x), y) for x, y in args[0].iteritems())
403403

404-
ack_response = conn.on_event(event['name'], **str_args)
404+
ack_response = conn.on_event(event['name'], kwargs=str_args)
405405
else:
406-
ack_response = conn.on_event(event['name'], *args)
406+
ack_response = conn.on_event(event['name'], args=args)
407407

408408
if msg_id:
409409
if msg_id.endswith('+'):

0 commit comments

Comments
 (0)
0