Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial fix #237 in client and #474 in server for duplicated reconnection in JSONP #342

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/socket.js
Expand Up @@ -48,6 +48,7 @@
this.namespaces = {};
this.buffer = [];
this.doBuffer = false;
this.lastHandshakeId = null;

if (this.options['sync disconnect on unload'] &&
(!this.isXDomain() || io.util.ua.hasCORS)) {
Expand Down Expand Up @@ -141,6 +142,8 @@
script.src = url + '&jsonp=' + io.j.length;
insertAt.parentNode.insertBefore(script, insertAt);

// store jsonp handshake-callback id
this.lastHandshakeId = io.j.length;
io.j.push(function (data) {
complete(data);
script.parentNode.removeChild(script);
Expand Down Expand Up @@ -200,6 +203,12 @@

var self = this;

// clear previous connection-callback to be shure we will not run into
// multi-restart issue for JSONP handshake
if (self.lastHandshakeId !== null) {
io.j[self.lastHandshakeId] = function () {};
}

this.handshake(function (sid, heartbeat, close, transports) {
self.sessionid = sid;
self.closeTimeout = close * 1000;
Expand Down