mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
style
This commit is contained in:
@@ -206,7 +206,7 @@ Socket.prototype.open = function () {
|
||||
var transport;
|
||||
if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
|
||||
transport = 'websocket';
|
||||
} else if (0 == this.transports.length) {
|
||||
} else if (0 === this.transports.length) {
|
||||
// Emit error on next tick so it can be listened to
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
@@ -538,7 +538,7 @@ Socket.prototype.onDrain = function() {
|
||||
// and a nonzero prevBufferLen could cause problems on `drain`
|
||||
this.prevBufferLen = 0;
|
||||
|
||||
if (this.writeBuffer.length == 0) {
|
||||
if (0 === this.writeBuffer.length) {
|
||||
this.emit('drain');
|
||||
} else {
|
||||
this.flush();
|
||||
@@ -630,24 +630,6 @@ Socket.prototype.close = function () {
|
||||
|
||||
var self = this;
|
||||
|
||||
function close() {
|
||||
self.onClose('forced close');
|
||||
debug('socket closing - telling transport to close');
|
||||
self.transport.close();
|
||||
}
|
||||
|
||||
function cleanupAndClose() {
|
||||
self.removeListener('upgrade', cleanupAndClose);
|
||||
self.removeListener('upgradeError', cleanupAndClose);
|
||||
close();
|
||||
}
|
||||
|
||||
function waitForUpgrade() {
|
||||
// wait for upgrade to finish since we can't send packets while pausing a transport
|
||||
self.once('upgrade', cleanupAndClose);
|
||||
self.once('upgradeError', cleanupAndClose);
|
||||
}
|
||||
|
||||
if (this.writeBuffer.length) {
|
||||
this.once('drain', function() {
|
||||
if (this.upgrading) {
|
||||
@@ -663,6 +645,24 @@ Socket.prototype.close = function () {
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
self.onClose('forced close');
|
||||
debug('socket closing - telling transport to close');
|
||||
self.transport.close();
|
||||
}
|
||||
|
||||
function cleanupAndClose() {
|
||||
self.removeListener('upgrade', cleanupAndClose);
|
||||
self.removeListener('upgradeError', cleanupAndClose);
|
||||
close();
|
||||
}
|
||||
|
||||
function waitForUpgrade() {
|
||||
// wait for upgrade to finish since we can't send packets while pausing a transport
|
||||
self.once('upgrade', cleanupAndClose);
|
||||
self.once('upgradeError', cleanupAndClose);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user