diff options
Diffstat (limited to 'js/src/Ice/browser/WSTransceiver.js')
-rw-r--r-- | js/src/Ice/browser/WSTransceiver.js | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js index b80c16318e2..5ecee521186 100644 --- a/js/src/Ice/browser/WSTransceiver.js +++ b/js/src/Ice/browser/WSTransceiver.js @@ -51,7 +51,7 @@ class WSTransceiver writeReadyTimeout() { - var t = Math.round(this._writeReadyTimeout); + const t = Math.round(this._writeReadyTimeout); this._writeReadyTimeout += (this._writeReadyTimeout >= 5 ? 5 : 0.2); return Math.min(t, 25); } @@ -183,26 +183,27 @@ class WSTransceiver } Debug.assert(this._fd); - var transceiver = this; - var cb = function() - { - if(transceiver._fd) - { - if(transceiver._fd.bufferedAmount + packetSize <= transceiver._maxSendPacketSize) - { - transceiver._bytesWrittenCallback(0, 0); - } - else - { - Timer.setTimeout(cb, transceiver.writeReadyTimeout()); - } - } - }; + const cb = () => + { + if(this._fd) + { + const packetSize = this._maxSendPacketSize > 0 && byteBuffer.remaining > this._maxSendPacketSize ? + this._maxSendPacketSize : byteBuffer.remaining; + if(this._fd.bufferedAmount + packetSize <= this._maxSendPacketSize) + { + this._bytesWrittenCallback(0, 0); + } + else + { + Timer.setTimeout(cb, this.writeReadyTimeout()); + } + } + }; while(true) { - var packetSize = (this._maxSendPacketSize > 0 && byteBuffer.remaining > this._maxSendPacketSize) ? - this._maxSendPacketSize : byteBuffer.remaining; + const packetSize = this._maxSendPacketSize > 0 && byteBuffer.remaining > this._maxSendPacketSize ? + this._maxSendPacketSize : byteBuffer.remaining; if(byteBuffer.remaining === 0) { break; @@ -214,9 +215,9 @@ class WSTransceiver return false; } this._writeReadyTimeout = 0; - var slice = byteBuffer.b.slice(byteBuffer.position, byteBuffer.position + packetSize); + const slice = byteBuffer.b.slice(byteBuffer.position, byteBuffer.position + packetSize); this._fd.send(slice); - byteBuffer.position = byteBuffer.position + packetSize; + byteBuffer.position += packetSize; // // TODO: WORKAROUND for Safari issue. The websocket accepts all the @@ -246,7 +247,7 @@ class WSTransceiver return false; // No data available. } - var avail = this._readBuffers[0].byteLength - this._readPosition; + let avail = this._readBuffers[0].byteLength - this._readPosition; Debug.assert(avail > 0); while(byteBuffer.remaining > 0) @@ -257,7 +258,7 @@ class WSTransceiver } new Uint8Array(byteBuffer.b).set(new Uint8Array(this._readBuffers[0], this._readPosition, avail), - byteBuffer.position); + byteBuffer.position); byteBuffer.position += avail; this._readPosition += avail; @@ -292,8 +293,8 @@ class WSTransceiver getInfo() { Debug.assert(this._fd !== null); - var info = new Ice.WSConnectionInfo(); - var tcpinfo = new Ice.TCPConnectionInfo(); + const info = new Ice.WSConnectionInfo(); + const tcpinfo = new Ice.TCPConnectionInfo(); tcpinfo.localAddress = ""; tcpinfo.localPort = -1; tcpinfo.remoteAddress = this._addr.host; @@ -369,9 +370,8 @@ class WSTransceiver static createOutgoing(instance, secure, addr, resource) { - var transceiver = new WSTransceiver(instance); - - var url = secure ? "wss" : "ws"; + const transceiver = new WSTransceiver(instance); + let url = secure ? "wss" : "ws"; url += "://" + addr.host; if(addr.port !== 80) { @@ -385,7 +385,6 @@ class WSTransceiver transceiver._state = StateNeedConnect; transceiver._secure = secure; transceiver._exception = null; - return transceiver; } } |