Fix check of readyState for immediate close
This commit is contained in:
@@ -57,9 +57,7 @@ var API = {
|
||||
close: function(code, reason, ack) {
|
||||
if (this.readyState === API.CLOSING ||
|
||||
this.readyState === API.CLOSED) return;
|
||||
|
||||
this.readyState = API.CLOSING;
|
||||
|
||||
|
||||
var close = function() {
|
||||
this.readyState = API.CLOSED;
|
||||
if (this._pingLoop) clearInterval(this._pingLoop);
|
||||
@@ -68,15 +66,19 @@ var API = {
|
||||
event.initEvent('close', false, false);
|
||||
this.dispatchEvent(event);
|
||||
};
|
||||
|
||||
|
||||
if (this.readyState === API.CONNECTING) {
|
||||
close.call(this);
|
||||
} else if (ack !== false) {
|
||||
if (this._parser.close) this._parser.close(code, reason, close, this);
|
||||
else close.call(this);
|
||||
} else {
|
||||
if (this._parser.close) this._parser.close(code, reason);
|
||||
close.call(this);
|
||||
this.readyState = API.CLOSING;
|
||||
|
||||
if (ack !== false) {
|
||||
if (this._parser.close) this._parser.close(code, reason, close, this);
|
||||
else close.call(this);
|
||||
} else {
|
||||
if (this._parser.close) this._parser.close(code, reason);
|
||||
close.call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user